diff --git a/Source/Config/Validate.php b/Source/Config/Validate.php new file mode 100644 index 0000000..99c7a54 --- /dev/null +++ b/Source/Config/Validate.php @@ -0,0 +1,115 @@ += 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; + } + + /** + * Vérifie si le mot-clé est valide. + * + * @param string $keyword Le mot-clé à vérifier. + * @return bool Vrai si le mot-clé est valide, faux sinon. + */ + + static function keyWord($keyword) : bool + { + global $keyWordMaxLength; + if (isset($keyword) && strlen($keyword) <= $keyWordMaxLength && strlen($keyword) >= 3) + return true; + else return false; + } + + /** + * Vérifie si le titre est valide. + * + * @param string $title Le titre à vérifier. + * @return bool Vrai si le titre est valide, faux sinon. + */ + + static function title($title) : bool + { + global $titleMaxLength; + if (isset($title) && strlen($title) <= $titleMaxLength && strlen($title) >= 3) + return true; + else return false; + } + + /** + * Vérifie si le type est valide. + * + * @param string $type Le type à vérifier. + * @return bool Vrai si le type est valide, faux sinon. + */ + + static function type($type) : bool + { + global $typeMaxLength; + if (isset($type) && strlen($type) <= $typeMaxLength && strlen($type) >=3) + return true; + else return false; + } + + /** + * Vérifie si la réponse est valide. + * + * @param string $response La réponse à vérifier. + * @return bool Vrai si la réponse est valide, faux sinon. + */ + + static function response($response) : bool{ + global $responseMaxLength; + if(isset($response) && strlen($response) <= $responseMaxLength) + return true; + else return false; + } +} \ No newline at end of file diff --git a/Source/Config/config.php b/Source/Config/config.php index ca79ae9..6ac43ef 100644 --- a/Source/Config/config.php +++ b/Source/Config/config.php @@ -1,3 +1,4 @@ +