fix(@angular-devkit/schematics-cli): prevent bypassing select/checkbox prompts on validation failure

Previously, when a select or checkbox prompt failed validation, it was bypassed, preventing users from correcting their input. This commit ensures that when validation fails, the prompts are re-displayed, allowing users to make the necessary corrections. This improves the user experience and helps avoid unintended selections.

Closes #28189
This commit is contained in:
Alan Agius 2024-08-12 08:29:28 +00:00 committed by Alan Agius
parent c5ed0b1248
commit 73c2437965

View File

@ -96,6 +96,13 @@ function _createPromptProvider(): schema.PromptProvider {
)({
message: definition.message,
default: definition.default,
validate: (values) => {
if (!definition.validator) {
return true;
}
return definition.validator(Object.values(values).map(({ value }) => value));
},
choices: definition.items.map((item) =>
typeof item == 'string'
? {