issue: Number validation "max" is ignored #11066
Replies: 2 comments 1 reply
-
There are several points to be addressed here: first, the way you define your register("field", {
required: "This is required",
min: {
value: 1,
message: "Min value is 1"
},
max: {
value: 10,
message: "Max value is 10"
}
}) This way you can access the errors.minimum_budget?.message // this will display "Min value is 1", "Max value is 10" or "This is required" Otherwise you'll try to display an empty string, which is the default value for the Second, the validation |
Beta Was this translation helpful? Give feedback.
-
Thank you for the solution, I'd recommend putting this in your documentation as it alluded 3 of our devs including myself. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Version Number
7.45.1
Codesandbox/Expo snack
https://codesandbox.io/p/sandbox/red-glade-kdzg3c?file=%2Fapp%2Fpage.tsx%3A28%2C30
Steps to reproduce
Expected behavior
It should show a validation error when the integer exceeds the set maximum.
What browsers are you seeing the problem on?
No response
Relevant log output
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions