Outcome Recipes
Outcome-focused validation scenarios that show how to wire Aurelia's validation controller, rules, and presenters for real forms.
1. Instant inline validation feedback
Steps
Aurelia.register(ValidationHtmlConfiguration);import { IValidationRules } from '@aurelia/validation'; import { IValidationController } from '@aurelia/validation-html'; import { newInstanceForScope, resolve } from '@aurelia/kernel'; export class SignupForm { person = { name: '', email: '' }; controller = resolve(newInstanceForScope(IValidationController)); constructor(private rules = resolve(IValidationRules)) { this.rules .on(this.person) .ensure('name').required() .ensure('email').required().email(); } }<form submit.trigger="controller.validate()"> <div validation-errors.from-view="nameErrors"> <label> Name <input value.bind="person.name & validate:changeOrBlur"> </label> <ul if.bind="nameErrors?.length"> <li repeat.for="error of nameErrors">${error.result.message}</li> </ul> </div> <div validation-errors.from-view="emailErrors"> <label> Email <input value.bind="person.email & validate:changeOrBlur"> </label> <p class="error" repeat.for="error of emailErrors">${error.result.message}</p> </div> </form>
Checklist
2. Step-by-step wizard gating
Steps
Checklist
3. Merge API validation errors
Steps
Checklist
4. Validate only changed fields on large forms
Steps
Checklist
5. Cross-field confirmation (password + confirm password)
Steps
Checklist
6. Async validation against a backend
Steps
Checklist
Validation flow cheat sheet
Outcome
Use this controller call
Template helpers
Last updated
Was this helpful?