ajout fonction pour valider password

php
Anthony RICHARD 1 year ago
parent b29f3c3e3c
commit 967aabb3e4

@ -5,6 +5,8 @@ use Exception;
class Validation
{
private static $passwordMinLen = 12;
public static function val_action($action): string {
$safeAction = htmlspecialchars($action, ENT_QUOTES);
if (!isset($action))
@ -14,6 +16,12 @@ class Validation
else return $safeAction;
}
public static function val_password($value): string {
if ($value == null || !preg_match('/^(?=.*[a-z])(?=.*[A-Z])(?=.*\W)(?!.*\s).{' . Validation::$passwordMinLen . ',}$/', $value))
throw new Exception("invalid password format");
return $value;
}
public static function filter_int($value): int {
if ($value == null || !filter_var($value, FILTER_VALIDATE_INT) || $value < 0)
throw new Exception("invalid field");

Loading…
Cancel
Save