You'll learn how to add validation to your applications using a fluent rule API
and minimal changes to your templates.
To get started you'll need to install aurelia-validation
using npm install aurelia-validation
or jspm
install aurelia-validation. Afterwards
, add .plugin(PLATFORM.moduleName('aurelia-validation'))
to the configuration in your main.js to ensure the plugin is loaded at application startup.
Defining Rules : Aurelia Validation's standard rule engine uses a fluent syntax to define a set of rules.
There are five parts to the syntax :
* Selecting a property using .ensure
* Associating rules with the property using .required
, .matches
, etc
* Customizing property rules using .withMessage
, .when
, etc
* Sequencing rules using .then
* Applying the ruleset to a class or instance using .on