CascadeMode enum

Defines the behavior of rule execution when a validation failure occurs.

The CascadeMode enum is used to control whether the validation process should continue executing subsequent rules after a validation failure is encountered, or stop immediately after the first failure.

This is useful for optimizing validation performance or ensuring that only the most critical validation rules are checked first, potentially avoiding unnecessary validations after a failure.

Available Modes:

  • continueExecution: All validation rules for a property will be executed, even if one fails. This is the default behavior and is useful when you want to collect all possible validation errors for a property at once.

  • stopOnFirstFailure: Validation will stop as soon as the first validation rule fails for a property. This can be useful when you want to ensure that the most critical validation rules are checked first and to avoid redundant checks after a failure.

Example:

ruleFor((user) => user.password, key: 'password')
    .notEmpty()
    .minLength(8)
    .cascade(CascadeMode.stopOnFirstFailure);

In the example above, if the password is empty, the validation will stop immediately, and the minLength(8) rule will not be executed. This can be useful for optimizing performance or ensuring that more critical rules are evaluated first.

Inheritance
Available extensions

Values

continueExecution → const CascadeMode

Continue executing all validation rules for the property, even if one fails. This mode is useful when you want to collect all possible validation errors at once.

stopOnFirstFailure → const CascadeMode

Stop executing validation rules for the property as soon as the first failure is encountered. This mode is useful for optimizing validation performance or prioritizing critical checks.

Properties

hashCode int
The hash code for this object.
no setterinherited
index int
A numeric identifier for the enumerated value.
no setterinherited
name String

Available on Enum, provided by the EnumName extension

The name of the enum value.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Constants

values → const List<CascadeMode>
A constant List of the values in this enum, in order of their declaration.