Skip to content

Commit

Permalink
fix(@angular-devkit/schematics-cli): prevent bypassing select/checkbo…
Browse files Browse the repository at this point in the history
…x 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
  • Loading branch information
alan-agius4 committed Aug 12, 2024
1 parent c5ed0b1 commit 73c2437
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/angular_devkit/schematics_cli/bin/schematics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
? {
Expand Down

0 comments on commit 73c2437

Please sign in to comment.