ember-changeset
ember-changeset copied to clipboard
Solution for handling interdependent validations? ♻️
My team recently came across the need to validate a mutually dependent start and end date. The start date could not be before the end date and vice versa. It seems the changeset instance has no way to update the validations when a certain property changes. In this case, we needed to update the end date validation to account for a new start date and vice versa. We ended up having to directly modify the private _validator
property on the changeset before each validation.
Did we miss something. Is there a better way to accomplish this task? Ideally it would be great if there were a public method for updating the validator as needed. Or, maybe one could specify a validation dependency which might then automatically update the validator as this respective property changes.
Thanks! Do you have some code examples or minimum reproduction?
Correct me if I'm wrong @alexabreu, but I just wanted to input that your use case seems related to #201. F.Y.I. for you as well @snewcomer.
@danielcroy @alexbreu does #384 help? (note this is on the 3.0.0-beta series)