You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current behavior:
When Adding properties or rather object via the "entity validation" methodology, there seems to be an interesting scenario where my entities will not validate unless I call validate() in the form controller.validate({ object: person }).
For instance, if I have this:
ValidationRules
.ensure('firstName').required()
.ensure('lastName').required()
.ensureObject().satisfies((e) => {
return _.every(e.workDates, (d) => d.StartDate != null);
})
.withMessage('All dates must have a start date')
.on(this.employee)
and call controller.validate() with no arguments, everything will validate except the workDates object.
On the other hand, if I call controller.validate({object: this.employee}), itworks as expected and the employee.workDates object validates as expected.
This seems like a bug to me, but maybe this is expected behavior for some reason?
Thanks
The text was updated successfully, but these errors were encountered:
With ensure(propertyName), we know we need to validate rules associated with the property when a binding to the property changes.
With ensureObject() we don't know which properties should cause which rules to validate, so any rules applied using ensureObject() will only be validated when you call controller.validate() manually.
We're looking into an enhancement that would allow you to define which property changes should trigger custom rule validation in #279.
A quick work-around for you might be to do something like this:
<divchange.delegate="controller.validate()"><!-- bindings to workDates...StartDate --></div>
Any DOM change events that fire due to the user editing start dates would trigger the controller to validate. You could fine-tune this by passing an instruction to the validate method specifying the precise object and rules you want to validate (see docs for more info).
I'm submitting a bug report
Library Version:
0.12.2
Operating System:
Windows 10
Node Version:
5.4.1
NPM Version:
3.3.12
JSPM Version
JSPM 0.16.32
Browser:
all
Language:
TypeScript 1.8
Current behavior:
When Adding properties or rather object via the "entity validation" methodology, there seems to be an interesting scenario where my entities will not validate unless I call validate() in the form controller.validate({ object: person }).
For instance, if I have this:
ValidationRules
.ensure('firstName').required()
.ensure('lastName').required()
.ensureObject().satisfies((e) => {
return _.every(e.workDates, (d) => d.StartDate != null);
})
.withMessage('All dates must have a start date')
.on(this.employee)
this.controller.addObject(this.employee.workDates);
and call controller.validate() with no arguments, everything will validate except the workDates object.
On the other hand, if I call controller.validate({object: this.employee}), itworks as expected and the employee.workDates object validates as expected.
This seems like a bug to me, but maybe this is expected behavior for some reason?
Thanks
The text was updated successfully, but these errors were encountered: