-
-
Notifications
You must be signed in to change notification settings - Fork 128
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
Validation support for subproperties #283
Comments
that'll be useful to have |
todo: consider #332 when implementing this. |
Wouldn't it be more appropriate to create separate validation rules for Address and then allow a .valid on those rules? This is how NHibernate Validator works. I wouldn't want to define rules for a reusable class everywhere it is associated with another class. I really need this in my application. NHibernate Validator examples
|
Curious why this is on-hold? It seems like if binding supports binding paths then validation should as well! |
Is there an update on the status of this, is this still not supported? |
Also related: #442 |
I'm submitting a feature request
Current behavior:
Given the follwing template code:
<input type="hidden" value.bind="newEntry.address.street1 &validate" />
<input type="hidden" value.bind="newEntry.address.street2 &validate" />
<input type="hidden" value.bind="newEntry.address.city &validate" />
And the current validation code (using aurelia-validatejs)
this.validationRules = new ValidationRules()
.ensure("address.street1").required().length({minimum:5, maximum:50}).
.ensure("address.street2").length({minimum:5, maximum:50}).
.ensure("address.city").length({minimum:5, maximum:50}).
...
on(this.newEntry);
The validation controller passes to the validator for (street1, street2 and city)
the propertyName : street1,street2 or city (depending on the field being validated)
and the following object:
{
street1:"",
street2:"".
city:"",
}
Expected/desired behavior:
Expected behaviour would to pass the entire object being validated not just the object containing the sub-property,
e.g
{
address: {
street1:"",
street2:"".
city:"",
}
}
Also, the full "path" to the property from the object "root" e.g. address.street1 instead of "street1"
What is the motivation / use case for changing the behaviour?
The motivation for this change is due to how aurelia-validationjs stores the rules as metadata in the containing object (newEntry in this case).
It is unable to find any rules when the address object is passed to it.
Also we will need the full path of the property (e.g address.street1) as the rules for sub-properties are defined as, for example, "address.street1" not "street1". It needs the path to be able to find the correct rule.
The text was updated successfully, but these errors were encountered: