IsPassword
extends Base
in package
Password validator with configurable requirements.
Validates password strength based on configurable criteria including length, character types (uppercase, lowercase, digits, special characters). Provides flexible password policy enforcement for various security requirements.
Tags
Table of Contents
Properties
- $_maxLength : int|null
- $_minLength : int
- $_requireDigit : bool
- $_requireLowercase : bool
- $_requireSpecial : bool
- $_requireUppercase : bool
- $_specialChars : string
Methods
- __construct() : void
- Constructor to initialize password validation requirements.
- isValid() : bool
- Returns true if validation is successful
- validate() : bool
- Validates the password against configured requirements.
Properties
$_maxLength
private
int|null
$_maxLength
$_minLength
private
int
$_minLength
$_requireDigit
private
bool
$_requireDigit
$_requireLowercase
private
bool
$_requireLowercase
$_requireSpecial
private
bool
$_requireSpecial
$_requireUppercase
private
bool
$_requireUppercase
$_specialChars
private
string
$_specialChars
Methods
__construct()
Constructor to initialize password validation requirements.
public
__construct(int $minLength[, int|null $maxLength = null ][, bool $requireUppercase = false ][, bool $requireLowercase = false ][, bool $requireDigit = false ][, bool $requireSpecial = false ][, string $specialChars = '!@#$%^&*()_+-=[]{}|;:,.<>?' ]) : void
Parameters
- $minLength : int
-
Minimum password length (required)
- $maxLength : int|null = null
-
Maximum password length, null for no limit (default: null)
- $requireUppercase : bool = false
-
Require at least one uppercase letter (default: false)
- $requireLowercase : bool = false
-
Require at least one lowercase letter (default: false)
- $requireDigit : bool = false
-
Require at least one digit (default: false)
- $requireSpecial : bool = false
-
Require at least one special character (default: false)
- $specialChars : string = '!@#$%^&*()_+-=[]{}|;:,.<>?'
-
Set of allowed special characters (default: !@#$%^&*()_+-=[]}|;:,.<>?)
isValid()
Returns true if validation is successful
public
isValid(mixed $value) : bool
Parameters
- $value : mixed
Return values
boolvalidate()
Validates the password against configured requirements.
protected
validate(mixed $value) : bool
Parameters
- $value : mixed
-
The password to validate
Return values
bool —True if the password meets all requirements, false otherwise