prompt support for value type number#12927
Closed
nweldev wants to merge 2 commits into
Closed
Conversation
As the ajv self validator was expecting a number, and the prompt delivered a string to the validator, the user was stuck in a loop with an impossible expectation. Now, the value from the prompt is converted to a number if required before validation.
Convert the inquirer result to a number iff the schematic option type is 'number'.
Member
|
Thank you for the contribution. We haven't forgotten about this PR. We are working on some infrastructure improvements to prompts that should simplify what is being attempt here. We'll update this thread once the PR is out. |
Member
|
Closing as the CLI currently supports the use of a schema property's type when validating and returning the value from a prompt. This includes both the |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Permit to support x-prompt for a schematic parameter definition if its type is set to number.
Previously, if used with type 'number', the prompt was trap in a loop as input never was considered correct.
The part on the cli will also need to be reproduced on schematics-cli after #12814.
Related to #12163.
Root causes
angular-devkit/core & ajv
Type number wasn't set, and the value wasn't converted to a number if needed in the prompt validator.
angular-devkit/cli & inquirer
Inquirer doesn't convert it result to a number even if definition type is set to 'number' following SBoudrias/Inquirer.js#663
Reproduction steps
You can reproduce the previous behavior by using the @angular-buddies/prettier@1.0.0-alpha.2:prettier-config schematic.
https://github.com/angular-buddies/angular-buddies/blob/v1.0.0-alpha.2/packages/prettier/src/config/schema.json#L14-L19