-
Notifications
You must be signed in to change notification settings - Fork 183
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
Populator is not called when the form fragment is nil #400
Comments
I think it's likely to be related to |
The populator is not called for a |
Any suggested areas of Reform or it's dependencies you suggest I poke around in? Any kinds of test cases that would be useful to provide? |
I've encountered this issue trying to validate that a valid nested property (user) is set on a parent form. If I pass in It would sort of make sense for the populator to be skipped if the input fragment was completely ignored and not written to the form. But skipping the user (Note that I only get an invalid user saved if the form is initialized with a new user - that new user gets saved.) |
@ollieh-m you can solve your validation issue (if you're using dry-validation) but writing your validations on the parent: Otherwise, you'd have to write a custom validator on the parent to check that |
Thanks @fran-worley. I'm not using dry-validation but I guess that's another reason to make the leap. I have got round the validation issue by just validating that user is present - so if user is set to nil, or is completely missing with no user form provided on initialization, the validation will fail... |
Has there been any insight on this in the last few years? I came across this issue today because my populator wouldn't run (and the property was given a nil). |
I have an existing API that passes
nil
for certain values that should actually be missing. To deal with this in a constrained manner, I'd like my form object to handle that.After flailing around with
skip_if
, I was pointed towardspopulate
. However, it appears that a populator is not called when the fragment isnil
:This code will print
If I change the input to any other value:
form.validate("name" => "")
, then the populator is called, theskip!
executed, and the output is correct:It feels incorrect that an explicit
nil
does not trigger the populator but it does set the value tonil
.Reform 2.2.1 with Ruby 2.3.1p112 on OS X
The text was updated successfully, but these errors were encountered: