Closed vishal-gits closed 4 months ago
max
is the number amount, not the number of digits. max(10)
means the number can't be greater than 10
Ok thanks, in case of strings, it represents the number of characters, but in case of numbers, it is the number amount. So is there a method available in yup to limit the number of integers in the input box.
What could be a solution to restrict for an input field of postalcode, so that it is a number of 5/6 digits.
Another Issue I am facing is -----(kindly confirm, if seperate issue needs to be raised for this) Also if typeError() is given to phone(which is not specified required), and when nothing is entered for phone, then also it attaches a typeError to it. Ideally if nothing is entered and it is not specified "required", it should not give an error.
phone: yup.number().max(10, "Max 10 dijits"),
this is a part of a validation schema used in react native in TextInput
Now when phone number is entered in numbers, whether it is less than or more than 10 , the validator gives an error- "Max 10 digits" and it does not remove the error , even after correcting it. Same is with postalCode.
Also if typeError() is given to phone(which is not specified required), and when nothing is entered for phone, then also it attaches a typeError to it. Ideally if nothing is entered and it is not specified "required", it should not give an error