aurelia / validatejs

Enables expressive validation using decorators and/or a fluent API.
MIT License
22 stars 23 forks source link

Feature request: Add support for conditional validation. #101

Closed MikaelPorttila closed 8 years ago

MikaelPorttila commented 8 years ago

The old validation had support for conditional validation with fluent-style if-statements. This feature appears to be missing in the new Aurelia-ValidateJS.

teves-castro commented 8 years ago

I'm not exactly sure what your scenario is, but I've managed to solve what I think is a similar issue by doing something like the following: ValidationRules.ensure("fieldToValidate").presence((value, self) => self.minOccurs > 0) Hope this helps.

EisenbergEffect commented 8 years ago

I don't think we're going to add conditional validation itself. However, we're working on a plan to enable custom validation rules. With that capability, you could implement a conditional validation system for your own app or even a plugin for the community. The best approach is to usually build what suits your own app best though since that will keep the core business logic firmly seated in your hands, rather than in ours, which is better for your long term.