|
|
|
@ -11,13 +11,10 @@ class Validate
|
|
|
|
|
* @return bool Vrai si l'adresse e-mail est valide et respecte la longueur maximale définie, faux sinon.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static function email (String $email): bool
|
|
|
|
|
public static function email (String $email): bool
|
|
|
|
|
{
|
|
|
|
|
global $emailMaxLength;
|
|
|
|
|
if(filter_var($email, FILTER_VALIDATE_EMAIL) && strlen($email) <= $emailMaxLength){
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else return false;
|
|
|
|
|
return (filter_var($email, FILTER_VALIDATE_EMAIL) && strlen($email) <= $emailMaxLength);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -28,13 +25,10 @@ class Validate
|
|
|
|
|
* @return bool Vrai si le pseudo est valide, faux sinon.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static function pseudo(string $pseudo) : bool
|
|
|
|
|
public static function pseudo(string $pseudo) : bool
|
|
|
|
|
{
|
|
|
|
|
global $pseudoMaxLength;
|
|
|
|
|
if(strlen($pseudo) >= 3 && preg_match("#[a-zA-Z0-9]+#", $pseudo) && strlen($pseudo) <= $pseudoMaxLength){
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else return false;
|
|
|
|
|
return (strlen($pseudo) >= 3 && preg_match("#[a-zA-Z0-9]+#", $pseudo) && strlen($pseudo) <= $pseudoMaxLength);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -45,13 +39,10 @@ class Validate
|
|
|
|
|
* @return bool Vrai si le mot de passe est valide, faux sinon.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static function password(string $password) : bool
|
|
|
|
|
public static function password(string $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;
|
|
|
|
|
return (strlen($password) >= 8 && strlen($password) <=$passwordMaxLength && preg_match("#[0-9]+#", $password) && preg_match("#[a-zA-Z]+#", $password));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -61,12 +52,10 @@ class Validate
|
|
|
|
|
* @return bool Vrai si le mot-clé est valide, faux sinon.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static function keyWord(string $keyword) : bool
|
|
|
|
|
public static function keyWord(string $keyword) : bool
|
|
|
|
|
{
|
|
|
|
|
global $keyWordMaxLength;
|
|
|
|
|
if (strlen($keyword) <= $keyWordMaxLength && strlen($keyword) >= 3)
|
|
|
|
|
return true;
|
|
|
|
|
else return false;
|
|
|
|
|
return (strlen($keyword) <= $keyWordMaxLength && strlen($keyword) >= 3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -76,12 +65,10 @@ class Validate
|
|
|
|
|
* @return bool Vrai si le titre est valide, faux sinon.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static function title(string $title) : bool
|
|
|
|
|
public static function title(string $title) : bool
|
|
|
|
|
{
|
|
|
|
|
global $titleMaxLength;
|
|
|
|
|
if (strlen($title) <= $titleMaxLength && strlen($title) >= 3)
|
|
|
|
|
return true;
|
|
|
|
|
else return false;
|
|
|
|
|
return (strlen($title) <= $titleMaxLength && strlen($title) >= 3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -91,12 +78,10 @@ class Validate
|
|
|
|
|
* @return bool Vrai si le type est valide, faux sinon.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static function type(string $type) : bool
|
|
|
|
|
public static function type(string $type) : bool
|
|
|
|
|
{
|
|
|
|
|
global $typeMaxLength;
|
|
|
|
|
if (strlen($type) <= $typeMaxLength && strlen($type) >=3)
|
|
|
|
|
return true;
|
|
|
|
|
else return false;
|
|
|
|
|
return (strlen($type) <= $typeMaxLength && strlen($type) >=3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -106,10 +91,8 @@ class Validate
|
|
|
|
|
* @return bool Vrai si la réponse est valide, faux sinon.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static function response(string $response) : bool{
|
|
|
|
|
public static function response(string $response) : bool{
|
|
|
|
|
global $responseMaxLength;
|
|
|
|
|
if(strlen($response) <= $responseMaxLength)
|
|
|
|
|
return true;
|
|
|
|
|
else return false;
|
|
|
|
|
return (strlen($response) <= $responseMaxLength);
|
|
|
|
|
}
|
|
|
|
|
}
|