Creating groups of tagged rules to allow for re-use of Aurelia Validation rules.
Tagging rules involves marking a rule or ruleset for a property or an object with a string identifier, namely a tag. Later, the tag can be used to execute a specific set of rules selectively. Note that every set of rules defined on an object has a tag. When the tag is omitted, a default tag for the ruleset is used for the objects.
Tags can be defined both with objects and properties. Refer to the following examples.
/* tagged rule definition */// default tagvalidationRules.on(person).ensure('name')// specific tags on objectvalidationRules.on(person,'ruleset1')//....on(person,'ruleset2')//...// specific tag on property rulesvalidationRules.on(person).ensure('name').minLength(42).tag('ruleset1').minLength(84).tag('ruleset2')/* executing tagged rules */// default tagvalidator.validate(newValidateInstruction(person));validator.validate(newValidateInstruction(person,'name'));// specific object tagvalidator.validate(newValidateInstruction(person,undefined,'ruleset1'));// specific property tagvalidator.validate(newValidateInstruction(person,'name',undefined,'ruleset1'));