Tagging Rules
Creating groups of tagged rules to allow for re-use of Aurelia Validation rules.
/* tagged rule definition */
// default tag
validationRules
.on(person)
.ensure('name')
// specific tags on object
validationRules
.on(person, 'ruleset1')
//...
.on(person, 'ruleset2')
//...
// specific tag on property rules
validationRules
.on(person)
.ensure('name')
.minLength(42)
.tag('ruleset1')
.minLength(84)
.tag('ruleset2')
/* executing tagged rules */
// default tag
validator.validate(new ValidateInstruction(person));
validator.validate(new ValidateInstruction(person, 'name'));
// specific object tag
validator.validate(new ValidateInstruction(person, undefined, 'ruleset1'));
// specific property tag
validator.validate(new ValidateInstruction(person, 'name', undefined, 'ruleset1'));Last updated
Was this helpful?