diff --git a/Source/Config/Validate.php b/Source/Config/Validate.php new file mode 100644 index 0000000..0520d83 --- /dev/null +++ b/Source/Config/Validate.php @@ -0,0 +1,60 @@ += 3 && preg_match("#[a-zA-Z0-9]+#", $pseudo) && strlen($pseudo) <= $pseudoMaxLength){ + return true; + } + else return false; + } + + /** + * Valide un mot de passe en vérifiant que la longueur est suffisante, qu'il contient au moins un chiffre et une lettre, + * et qu'il respecte la longueur maximale définie globalement. + * + * @param string $password Le mot de passe à valider. + * @return bool Vrai si le mot de passe est valide, faux sinon. + */ + + static function password($password) : bool + { + global $passwordMaxLength; + if(strlen($password) >= 8 && strlen($password) <=$passwordMaxLength && preg_match("#[0-9]+#", $password) && preg_match("#[a-zA-Z]+#", $password)){ + return true; + } + else return false; + } + + + + +} \ No newline at end of file diff --git a/Source/Config/config.php b/Source/Config/config.php index 161d220..5a0ce6f 100644 --- a/Source/Config/config.php +++ b/Source/Config/config.php @@ -6,3 +6,7 @@ $rep = __DIR__ . '/../'; // Vues $views['form'] = 'Views/HTML/form.php'; $views['admin'] = 'Views/HTML/admin.php'; + +$emailMaxLength=150; +$pseudoMaxLength=50; +$passwordMaxLength=500; \ No newline at end of file