Aurelia 2 - Validator

I just went through the new validator and documentation.
Holey cow! That new format is awesome!

I am a hack, I admit it. I don’t spend all my time doing frontend code and am always having to go back and relearn some code usage or another. All the examples is absolutely going to make my relearning curve so much faster!

I cannot give enough kudos to the team and the direction docs seem to be moving.

7 Likes

Will the ValidationRules.ensure(...).rules (saving a “rules” object) approach still be supported? It does not seem to be present in the documentation at https://docs.aurelia.io/app-basics/validating-data.

1 Like

The API still supports exporting rules, but is slightly different form in contrast to Aurelia1.

IMO the rule export helps for selective validation. In that context, the support for tagged rules has been improved a lot. You can use the tags to selectively execute the rules for object and/or properties. IMO it is more ergonomic, and easier to work with than to deal with the rules.

Check the docs for rule tagging: https://docs.aurelia.io/app-basics/validating-data#tagging-rules
Also the corresponding demo: https://stackblitz.com/edit/au2-validation-tagging-rules

In case the tagged rules don’t serve your use-case, can you please elaborate your use-case?

1 Like

I am aware of tagged rules and I did notice they seem to have improved in usability; we will reconsider our use case when the time will come.

2 Likes