How to check that a value is a number or change the default error message?
See original GitHub issueHi,
I have the following schema defined.
const schema = yup.object().shape({
name: yup.string()
.required('name is required'),
age: yup.number()
.positive('age must be greater than zero')
.required('age is required')
});
I am also using this with react-formal. When I enter a value for myNumber form field that is not a number, say ‘abc’, I get the following error message:
this (value: ``) must be a `number` type
I’d like to specify the error message to display when the value is not a number but adding an error message to the number method doesn’t seem to work. Is there a way to do this?
Thanks
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:8
Top Results From Across the Web
Change the default error message in the model state ...
Model validation occurs after model binding and reports errors ... FirstValue; // Check if the argument value is null or empty if (string....
Read more >Video: Input and error messages - Microsoft Support
Select the cells that you want to create a message for, and click Data Validation. · On the Input Message tab, check the...
Read more >I get a message about data type mismatch
To troubleshoot this message, try the following: If you just changed the Default Value for a field in a table and see a...
Read more >Error.prototype.message - JavaScript - MDN Web Docs
This property contains a brief description of the error if one is available or has been set. The message property combined with the...
Read more >Default Validator Messages | JET Developer Cookbook
Set focus to see the datepicker and its enabled dates. Type a value out of range and step off the field to see...
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
I got it. I needed to call the typeError() function
See: https://tonicdev.com/dannief/572294ef4a2c861200c181e5
I found out 2 methods:
1. Not extremely strict: (Allows spaces in number input, if input type is text)
2. Strict, Doesn’t even allow spaces: (misses out on
number()
functions though)