Default values for string Input prompt are not passed to validators
See original GitHub issueIf a defaultValue
is specified in a Prompt.Input<string>
call that also specifies validators, pressing Enter on the prompt sends an empty string to the validators, not the default value. For example:
var userName = Sharprompt.Prompt.Input<string>("Please enter a name", "default", validators: new[] { Sharprompt.Validations.Validators.Required()});
will fail unless providing a non-default value, since an empty string is passed to validators, rather than the default value specified by defaultValue
.
I’ve created an oversimplified repro in this repo
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
If no value provided, Default value will not pass validation
I'm prompting the user to input a year in YYYY format. If the user inputs four digits everything works as expected. If the...
Read more >Html5 validate input value not eqaul to by default value
I want to validate input value not equal to by default value through html5 validation,is it possible? <input type="text" name="First Name" value ......
Read more >Why the number input is the worst input
If you need a number input that has no conditional validation (i.e. number is always within a certain range of min/max) and has...
Read more >Chapter 8 – Input Validation
Input validation code checks that values entered by the user, such as text from the input() function, are formatted correctly.
Read more ><input type="text"> - HTML: HyperText Markup Language | MDN
If no validation constraints are in place for the input (see Validation for more details), the value may be an empty string (...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes
Yes
The message display will be corrected in #87.