LogoLogo
HomeDiscourseBlogDiscord
  • Introduction
  • Introduction
    • Quick start
    • Aurelia for new developers
    • Hello world
      • Creating your first app
      • Your first component - part 1: the view model
      • Your first component - part 2: the view
      • Running our app
      • Next steps
  • Templates
    • Template Syntax
      • Attribute binding
      • Event binding
      • Text interpolation
      • Template promises
      • Template references
      • Template variables
      • Globals
    • Custom attributes
    • Value converters (pipes)
    • Binding behaviors
    • Form Inputs
    • CSS classes and styling
    • Conditional Rendering
    • List Rendering
    • Lambda Expressions
    • Local templates (inline templates)
    • SVG
  • Components
    • Component basics
    • Component lifecycles
    • Bindable properties
    • Styling components
    • Slotted content
    • Scope and context
    • CustomElement API
    • Template compilation
      • processContent
      • Extending templating syntax
      • Modifying template parsing with AttributePattern
      • Extending binding language
      • Using the template compiler
      • Attribute mapping
  • Getting to know Aurelia
    • Routing
      • @aurelia/router
        • Getting Started
        • Creating Routes
        • Routing Lifecycle
        • Viewports
        • Navigating
        • Route hooks
        • Router animation
        • Route Events
        • Router Tutorial
        • Router Recipes
      • @aurelia/router-lite
        • Getting started
        • Router configuration
        • Configuring routes
        • Viewports
        • Navigating
        • Lifecycle hooks
        • Router hooks
        • Router events
        • Navigation model
        • Transition plan
    • App configuration and startup
    • Enhance
    • Template controllers
    • Understanding synchronous binding
    • Dynamic composition
    • Portalling elements
    • Observation
      • Observing property changes with @observable
      • Effect observation
      • HTML observation
      • Using observerLocator
    • Watching data
    • Dependency injection (DI)
    • App Tasks
    • Task Queue
    • Event Aggregator
  • Developer Guides
    • Animation
    • Testing
      • Overview
      • Testing attributes
      • Testing components
      • Testing value converters
      • Working with the fluent API
      • Stubs, mocks & spies
    • Logging
    • Building plugins
    • Web Components
    • UI virtualization
    • Errors
      • 0001 to 0023
      • 0088 to 0723
      • 0901 to 0908
    • Bundlers
    • Recipes
      • Apollo GraphQL integration
      • Auth0 integration
      • Containerizing Aurelia apps with Docker
      • Cordova/Phonegap integration
      • CSS-in-JS with Emotion
      • DOM style injection
      • Firebase integration
      • Markdown integration
      • Multi root
      • Progress Web Apps (PWA's)
      • Securing an app
      • SignalR integration
      • Strongly-typed templates
      • TailwindCSS integration
      • WebSockets Integration
      • Web Workers Integration
    • Playground
      • Binding & Templating
      • Custom Attributes
        • Binding to Element Size
      • Integration
        • Microsoft FAST
        • Ionic
    • Migrating to Aurelia 2
      • For plugin authors
      • Side-by-side comparison
    • Cheat Sheet
  • Aurelia Packages
    • Validation
      • Validation Tutorial
      • Plugin Configuration
      • Defining & Customizing Rules
      • Architecture
      • Tagging Rules
      • Model Based Validation
      • Validation Controller
      • Validate Binding Behavior
      • Displaying Errors
      • I18n Internationalization
      • Migration Guide & Breaking Changes
    • i18n Internationalization
    • Fetch Client
      • Overview
      • Setup and Configuration
      • Response types
      • Working with forms
      • Intercepting responses & requests
      • Advanced
    • Event Aggregator
    • State
    • Store
      • Configuration and Setup
      • Middleware
    • Dialog
  • Tutorials
    • Building a ChatGPT inspired app
    • Building a realtime cryptocurrency price tracker
    • Building a todo application
    • Building a weather application
    • Building a widget-based dashboard
    • React inside Aurelia
    • Svelte inside Aurelia
    • Synthetic view
    • Vue inside Aurelia
  • Community Contribution
    • Joining the community
    • Code of conduct
    • Contributor guide
    • Building and testing aurelia
    • Writing documentation
    • Translating documentation
Powered by GitBook
On this page
  • A list of differences
  • Functionality is now in three different packages
  • Rules are defined differently using ValidationRules
  • Named registration of custom rules is no longer supported
  • The validator interface only has one method
  • Validation controller factory usage changed
  • Validation renderer has been removed

Was this helpful?

Export as PDF
  1. Aurelia Packages
  2. Validation

Migration Guide & Breaking Changes

Creating and customing Aurelia Validation rules to ensure data is validated.

PreviousI18n InternationalizationNexti18n Internationalization

Last updated 1 year ago

Was this helpful?

This section outlines the breaking changes introduced by @aurelia/validation* as compared to the predecessor aurelia-validation. However, it is recommended that you read the documentation, as many new features have been added.

A list of differences

Functionality is now in three different packages

Instead of a single validation package, the functionalities are arranged in . These are @aurelia/validation (provides core functionalities), @aurelia/validation-html (provides integration with the view), and @aurelia/validation-i18n (provides localization support for validation in view).

Rules are defined differently using ValidationRules

Usage of ValidationRules in terms of defining rules is a bit different. The example below shows the difference. Refer to the section for the details.

// aurelia-validation
  ValidationRules
    .ensure('firstName')
      .required()
    .on(this.person);

// @aurelia/validation
import { IValidationRules } from '@aurelia/validation';
//...
constructor(
  validationRules: IValidationRules = resolve(IValidationRules)
) {
  ValidationRules
    .on(this.person)
    .ensure('firstName')
      .required();
}

Named registration of custom rules is no longer supported

// aurelia-validation
ValidationRules.customRule(
  'customRule',
  // rule body
  // rule config
);

ValidationRules
  .ensure('property')
    .satisfiesRule('customRule' ...);

// @aurelia/validation
class CustomRule extends BaseValidationRule { // of implements IValidationRule
  // rule config
  public execute() {
    // rule body
  }
}

validationRules
  .on(obj)
  .ensure('property')
    .satisfiesRule(new CustomRule(...));

The validator interface only has one method

Validation controller factory usage changed

Validation renderer has been removed

Named registration of reusable custom rules is no longer supported in favor of simply using an instance of the rule implementation. The example below shows the difference. Refer to the section for the details.

The validator interface has been changed to have only one validate method equipped with validation instructions. Refer to the section for the details.

The usage of the validation controller factory is changed. Instead of using controllerFactory.createForCurrentScope(); , you need to inject the newInstanceForScope(IValidationController) (example: resolve(newInstanceForScope(IValidationController))). Refer to the section for the details.

No validation renderer in favor of ValidationResultsSubscriber. Refer to the section for the details.

three different packages
Defining rules
Customizing rules
Validator and validate instruction
Injecting a controller instance
addSubscriber and removeSubscriber