SafePasswordValidator class

A validator for ensuring password strength and security requirements.

SafePasswordValidator checks passwords against common security criteria: digits, lowercase letters, uppercase letters, and special characters. Each requirement can be individually enabled or disabled.

Example:

SafePasswordValidator(
  requireDigit: true,
  requireLowercase: true,
  requireUppercase: true,
  requireSpecialChar: true,
  message: 'Password must meet security requirements',
)
Inheritance

Constructors

SafePasswordValidator({bool requireDigit = true, bool requireLowercase = true, bool requireUppercase = true, bool requireSpecialChar = true, String? message})
Creates a SafePasswordValidator with configurable requirements.
const

Properties

hashCode int
The hash code for this object.
no setteroverride
message String?
Custom error message, or null to use default localized messages.
final
requireDigit bool
Whether password must contain at least one digit.
final
requireLowercase bool
Whether password must contain at least one lowercase letter.
final
requireSpecialChar bool
Whether password must contain at least one special character.
final
requireUppercase bool
Whether password must contain at least one uppercase letter.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

combine(Validator<String> other) Validator<String>
Combines this validator with another validator using AND logic.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shouldRevalidate(FormKey source) bool
Determines if this validator should be re-run when the specified form key changes.
inherited
toString() String
A string representation of this object.
inherited
validate(BuildContext context, String? value, FormValidationMode state) FutureOr<ValidationResult?>
Validates the given value and returns a validation result.
override

Operators

operator &(Validator<String> other) Validator<String>
Combines this validator with another using AND logic (alias for combine).
inherited
operator +(Validator<String> other) Validator<String>
Combines this validator with another using AND logic (alias for combine).
inherited
operator ==(Object other) bool
The equality operator.
override
operator unary-() Validator<String>
Negates this validator's result (alias for ~ operator).
inherited
operator |(Validator<String> other) Validator<String>
Combines this validator with another using OR logic.
inherited
operator ~() Validator<String>
Negates this validator's result.
inherited