PasswordValidator class

PasswordValidator extends BaseValidator to validate if a string meets specified password requirements.

This validator checks the password for minimum length, maximum length, and the presence of uppercase, lowercase, numeric, and special characters based on the provided constraints.

Parameters:

  • minLength The minimum length of the password. Defaults to 8.
  • maxLength The maximum length of the password. Defaults to 32.
  • minUppercaseCount The minimum number of uppercase characters required. Defaults to 1.
  • minLowercaseCount The minimum number of lowercase characters required. Defaults to 1.
  • minNumberCount The minimum number of numeric characters required. Defaults to 1.
  • minSpecialCharCount The minimum number of special characters required. Defaults to 1.
  • errorText The error message returned if the validation fails.
  • checkNullOrEmpty Whether to check if the value is null or empty.
Inheritance

Constructors

PasswordValidator.new({int minLength = 8, int maxLength = 32, int minUppercaseCount = 1, int minLowercaseCount = 1, int minNumberCount = 1, int minSpecialCharCount = 1, String? errorText, bool checkNullOrEmpty = true})
Constructor for the password validator.
const

Properties

checkNullOrEmpty bool
Whether to check if the value is null or empty.
finalinherited
errorText String?
The error message returned if the value is invalid.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
maxLength int
The maximum length of the password.
final
minLength int
The minimum length of the password.
final
minLowercaseCount int
The minimum number of lowercase characters required.
final
minNumberCount int
The minimum number of numeric characters required.
final
minSpecialCharCount int
The minimum number of special characters required.
final
minUppercaseCount int
The minimum number of uppercase characters required.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

isNullOrEmpty(String? valueCandidate) bool
Checks if the value is null or empty. Returns true if the value is null or empty, otherwise false. The value is considered empty if it is a String, Iterable, or Map and it is empty or contains only whitespace characters. If the value is not a String, Iterable, or Map, it is considered empty if it is null.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
validate(String? valueCandidate) String?
Validates the value and checks if it is null or empty.
inherited
validateValue(String valueCandidate) String?
Validates the value. Returns null if the value is valid, otherwise an error message. Call validate() instead of this method when using the validator.
override

Operators

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