-
Notifications
You must be signed in to change notification settings - Fork 300
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
cannot validate complex object (v0.9.1) #224
Comments
we are also bumping into this |
Thirded, this is an issue for us too |
here is the question I posted on stack http://jsfiddle.net/captDaylight/rkz1dxfw/2/ |
I have the same problem too |
ran into this same issue today, trying to validate complex object. Is this issue still being looked at? In our case, we're using preValidate, in which we're trying to validate a complext object. |
Fixed by #260. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
per the documentation:
"Validating complex objects is also supported. To configure validation rules for objects, use dot notation in the name of the attribute, e.g 'address.street'."
with this approach, validation is failing. I think it's because of the code below from
validate
allAttrs = _.extend({}, validatedAttrs, model.attributes, attrs),
this effectively combines the validatedAttrs hash with the model attributes which results in allAttrs looking something like this (pretending we're validating the street of a person's address):
person : { attributes : { address : { attributes : { street : '1234' } } }, address.street : undefined }
later on, when this is validated,
flatten
will determine the attributes hash already has a propertyaddress.street
and will not properly flatten out the address object. If I removevalidatedAttrs
from the aforementioned_.extend(...)
the issue is resolved, however I don't know if this will negatively impact anything else during validation.I think if the structure was flattened first in a smart way using the validatedAttrs and THEN validatedAttrs was extended onto the resulting flattened structure to detect missing attrs, we'll be in good shape.
The text was updated successfully, but these errors were encountered: