ember-changeset icon indicating copy to clipboard operation
ember-changeset copied to clipboard

Solution for handling interdependent validations? ♻️

Open alexabreu opened this issue 5 years ago • 3 comments

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.

alexabreu avatar Sep 11 '19 15:09 alexabreu

Thanks! Do you have some code examples or minimum reproduction?

snewcomer avatar Oct 01 '19 11:10 snewcomer

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 avatar Nov 15 '19 21:11 danielcroy

@danielcroy @alexbreu does #384 help? (note this is on the 3.0.0-beta series)

snewcomer avatar Dec 07 '19 04:12 snewcomer