Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobaraujo7 committed Aug 24, 2024
1 parent c3436bb commit 8e07c48
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion lib/src/validator_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,28 @@ class LucidValidationBuilder<TProp, Entity> {
return this;
}

/// Changes the cascade mode for this validation.
/// Sets the [CascadeMode] for the validation rules associated with this property.
///
/// The [cascade] method allows you to control the behavior of rule execution when a validation failure occurs.
/// By default, all validation rules are executed even if one fails. However, by setting the [CascadeMode],
/// you can specify whether validation should stop after the first failure (`CascadeMode.stopOnFirstFailure`)
/// or continue executing all rules (`CascadeMode.continueExecution`).
///
/// [mode] is the [CascadeMode] that determines whether to continue or stop validation after a failure.
///
/// Returns the [LucidValidationBuilder] to allow for method chaining.
///
/// Example:
/// ```dart
/// 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.
LucidValidationBuilder<TProp, Entity> cascade(CascadeMode mode) {
_mode = mode;
return this;
Expand Down

0 comments on commit 8e07c48

Please sign in to comment.