Validating Zero
See original GitHub issueRequired validation triggers if my select returns number 0.
Setting custom validation rules don’t trigger when using setValue if I pass it number 0
register(
{
name: 'myProp'
},
{
required: 'whoops'
}
);
This triggers if setValue('myProp', 0, true);
Additionally
register(
{
name: 'myProp'
},
{
required: 'whoops',
validate: (id: number) => {
return (id > -1 && id !== 999) || 'whoops';
}
}
);
The validate function isn’t even called if I use setValue('myProp', 0, true);
I would expect the validate function to run every time there is an update. Also, how should 0 values be used? Selects might legitimately return the number 0.
The ideal solution would be a property which allows 0 as valid?
A quick fix is to cast everything as strings 😦
Any help is appreciated 😃
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Fix: Validating Steam Files Stuck At 0 - Appuals.com
Users often need to verify their game files and in this error, steam gets stuck at 0% when the process is initiated and...
Read more >How to create correct rule for validating zero via vee-validate
', validate: (value) => { // value must be > zero if (value > 0 ) return true; return false; } }); },....
Read more >ZeroBounce - Email Validation Service and Deliverability Toolkit
Easy and effective email validation service. 98% accuracy, 24/7 customer support. Verify 100 email addresses for free – every month! Start trial today....
Read more >Validating Zero Enum Value in the Protocol Buffer - HackerNoon
How to validate that a Protobuf message does not contain enum fields with zero value? Turn out that is not supported directly by...
Read more >Hibernate Validator 8.0.0.Final - Jakarta Bean Validation ...
Declaring and validating method constraints ... passedDrivingTest( true ); assertEquals( 0, validator.validate( car, DriverChecks.class ) ...
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 Free
Top 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
Thank you for the super fast response Bill!
As i’m using MUI and the select seems to need an empty string to be ‘clean’ i’m setting a defaultValue of an empty string.
Therefore for me the validation was super simple - removing
required
was the key.Is this covered in the docs and I missed it? Happy to do a PR otherwise
I am going to close this issue for now, i will let you know what to update on documentation later on if you still interested 😃 👍