liveBook · Manning

Validation state

As explained in Pro Angular 16

Validation state is the current condition of form data relative to the validation rules applied to it.

Validation state describes whether form data satisfies its validation rules and whether the user has interacted with the field. Angular updates this state automatically as input changes or focus moves. section 13.4.2

Angular exposes validation state through paired classes and validation-object properties:

  • The same classes appear on the form, summarizing the validation status of its elements. section 13.4.2

Delay feedback until editing

Apply input.ng-dirty.ng-invalid for a red border and input.ng-dirty.ng-valid for a green border. This avoids changing the appearance before the user edits the field. section 13.4.2

How Pro Angular 16 covers it

How deep it goes
Explains validation classes, object properties, CSS feedback, and conditional messages, while deferring custom validation rules.
Examples
Demonstrates product-name validation using required, minlength, pattern, CSS borders, and conditional error messages.
What it assumes
Assumes familiarity with Angular templates, forms, data binding, and basic HTML and CSS attributes.
What you can do after
Apply validation state to style fields and display targeted messages through Angular templates.
How it connects
Connects form validation with validation rules, ngModel, template-driven forms, validation classes, and validation error messages.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pro Angular 16. The section links point to the parts of the book it draws on.