-
Notifications
You must be signed in to change notification settings - Fork 935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
number().required().nullable() #1946
Comments
I have made a workaround: but I still think this is how number().required().nullable() should work together |
see the section about nullability: #1906 |
@jquense the migration guide only explains a migration path in the case of string cast, which is not the case here. The use case where a field is unset with a null value is fairly common, and I fail to see how the migration guide helps to migrate to the "new patterns". Is the workaround provided by ennoeller (rewrite a required function) the best way to solve that case? |
@Manny651 did you read the section? it applies to all schema and not just strings, it also outlines a migration path. As far as alternatives, they have been discussed a few times in the issues. You might want to use |
@jquense I think I misstated the problem: the doc section is all about the functions about casting and copying the data, but the issue here is encountered when trying to call the |
Hmm I'm not sure I understand what your asking for then. validating a nullable required schema has always resulted in an error, saying the field is missing. The only behavior change in v1 is for casting. If what your saying is you want a "this field is required" error instead of "field is the wrong type null" error, then I'd suggest changing the type error on your schema to say the field is required when the value is null |
Would like some clarification on a possible issue. When I mark my schema property as number().required().nullable() then I can not have the property value as null/no value. I would like to initiate a form with a numeric value "unset" or on an existing form change the value to null (temporarily till I edit the form). It would then be expected, that the form will not validate if a value is null, yet I can have an empty field while initiating or editing the form.
Would it classify as a bug or how could I achieve this?
The text was updated successfully, but these errors were encountered: