FormRules class

A small fluent helper to build validation rules for controls inside a FormGroup, with support for cross-field dependencies.

Why this exists:

  • dart_ng_forms allows attaching a single validator to a control.
  • In real forms, you often need to compose multiple validators and also re-validate a field when other fields change (cross-field rules).

Example:

final rules = FormRules(form);

rules.ruleFor<String>('password')
  .compose(notEmpty)
  .compose(minLength8)
  .dependsOn('username'); // re-validates password when username changes

// later...
rules.dispose();

Constructors

FormRules(FormGroup form)

Properties

form FormGroup
The form group that owns the controls.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() → void
Detaches all listeners registered through this instance.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
ruleFor<T>(String fieldName) RuleFor<T>
Creates a fluent rule builder for the given fieldName.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited