Setting up validation

Validation with aurelia-form is very simple. We've built a plugin for aurelia-form that takes away any boilerplate, making it work out of the box.

Enabling the plugin

To get validation set up, all you have to do is:

  1. Install the plugin
  2. Enable it in your config.

The following code snippets illustrate how to enable the plugin for your project.

Using aurelia-config

Aurelia-config makes it easy to register plugins and configure them.

  .plugin('aurelia-config', configure => {
    return configure([

Changing trigger

By default, the validation trigger is change. This means that any change in the form will trigger validation for the field that triggered the change. Other options are blur, changeOrBlur and manual.

Here's how you can change the trigger using the config.

import {validateTrigger} from 'aurelia-validation';

  .plugin('aurelia-config', configure => {
    return configure([
    ], {
      'aurelia-form': {
        validation: {
          trigger: validateTrigger.blur

Without aurelia-config

Aurelia-config is optional (but recommended!). Without aurelia-config, registering the plugins works exactly like expected:


Configurations can be supplied using the second argument.

Usage example

Enabling validation is enough to start validating, but you'll have to register validation rules to validate on your entities, too.

The following is an example based on aurelia-orm.


import {Entity, validatedResource, type} from 'aurelia-orm';
import {ValidationRules} from 'aurelia-validation';

export class TodoEntity extends Entity {

  todo = '';

  done = false;

  constructor() {



import {TodoEntity} from 'entity/todo';

export class Todo {
  constructor() {
    this.todo = new TodoEntity();


  <entity-form entity.bind="todo">

And there you have it, a fully functional form with validation set up.

All done

Now you have validation enabled!

results matching ""

    No results matching ""