Description
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 property address.street
and will not properly flatten out the address object. If I remove validatedAttrs
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.