Register
Already a member? Login here
/** * Validate password according to HKVCA production rules * Rules: * - Minimum 8 characters * - Maximum 128 characters * - Must contain at least one letter and one number * - Special characters allowed */ function validate_password(string $password): array { $errors = []; if (strlen($password) < 8) { $errors[] = "Password must be at least 8 characters long and must be composed of letters and numbers"; } if (strlen($password) > 128) { $errors[] = "Password cannot be longer than 128 characters."; } if (!preg_match('/[A-Za-z]/', $password)) { $errors[] = "Password must contain at least one letter."; } if (!preg_match('/[0-9]/', $password)) { $errors[] = "Password must contain at least one number."; } return $errors; // empty array = valid }
Already a member? Login here