|
|
@ -11,7 +11,7 @@ class Validate
|
|
|
|
* @return bool Vrai si l'adresse e-mail est valide et respecte la longueur maximale définie, faux sinon.
|
|
|
|
* @return bool Vrai si l'adresse e-mail est valide et respecte la longueur maximale définie, faux sinon.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
static function email (String $email)
|
|
|
|
static function email (String $email): bool
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $emailMaxLength;
|
|
|
|
global $emailMaxLength;
|
|
|
|
if(filter_var($email, FILTER_VALIDATE_EMAIL) && strlen($email) <= $emailMaxLength){
|
|
|
|
if(filter_var($email, FILTER_VALIDATE_EMAIL) && strlen($email) <= $emailMaxLength){
|
|
|
@ -28,7 +28,7 @@ class Validate
|
|
|
|
* @return bool Vrai si le pseudo est valide, faux sinon.
|
|
|
|
* @return bool Vrai si le pseudo est valide, faux sinon.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
static function pseudo($pseudo) : bool
|
|
|
|
static function pseudo(string $pseudo) : bool
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $pseudoMaxLength;
|
|
|
|
global $pseudoMaxLength;
|
|
|
|
if(strlen($pseudo) >= 3 && preg_match("#[a-zA-Z0-9]+#", $pseudo) && strlen($pseudo) <= $pseudoMaxLength){
|
|
|
|
if(strlen($pseudo) >= 3 && preg_match("#[a-zA-Z0-9]+#", $pseudo) && strlen($pseudo) <= $pseudoMaxLength){
|
|
|
@ -45,7 +45,7 @@ class Validate
|
|
|
|
* @return bool Vrai si le mot de passe est valide, faux sinon.
|
|
|
|
* @return bool Vrai si le mot de passe est valide, faux sinon.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
static function password($password) : bool
|
|
|
|
static function password(string $password) : bool
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $passwordMaxLength;
|
|
|
|
global $passwordMaxLength;
|
|
|
|
if(strlen($password) >= 8 && strlen($password) <=$passwordMaxLength && preg_match("#[0-9]+#", $password) && preg_match("#[a-zA-Z]+#", $password)){
|
|
|
|
if(strlen($password) >= 8 && strlen($password) <=$passwordMaxLength && preg_match("#[0-9]+#", $password) && preg_match("#[a-zA-Z]+#", $password)){
|
|
|
@ -57,14 +57,14 @@ class Validate
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Vérifie si le mot-clé est valide.
|
|
|
|
* Vérifie si le mot-clé est valide.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param string $keyword Le mot-clé à vérifier.
|
|
|
|
* @param string $keyword Le mot-clé a vérifié.
|
|
|
|
* @return bool Vrai si le mot-clé est valide, faux sinon.
|
|
|
|
* @return bool Vrai si le mot-clé est valide, faux sinon.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
static function keyWord($keyword) : bool
|
|
|
|
static function keyWord(string $keyword) : bool
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $keyWordMaxLength;
|
|
|
|
global $keyWordMaxLength;
|
|
|
|
if (isset($keyword) && strlen($keyword) <= $keyWordMaxLength && strlen($keyword) >= 3)
|
|
|
|
if (strlen($keyword) <= $keyWordMaxLength && strlen($keyword) >= 3)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
else return false;
|
|
|
|
else return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -72,14 +72,14 @@ class Validate
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Vérifie si le titre est valide.
|
|
|
|
* Vérifie si le titre est valide.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param string $title Le titre à vérifier.
|
|
|
|
* @param string $title Le titre a vérifié.
|
|
|
|
* @return bool Vrai si le titre est valide, faux sinon.
|
|
|
|
* @return bool Vrai si le titre est valide, faux sinon.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
static function title($title) : bool
|
|
|
|
static function title(string $title) : bool
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $titleMaxLength;
|
|
|
|
global $titleMaxLength;
|
|
|
|
if (isset($title) && strlen($title) <= $titleMaxLength && strlen($title) >= 3)
|
|
|
|
if (strlen($title) <= $titleMaxLength && strlen($title) >= 3)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
else return false;
|
|
|
|
else return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -87,14 +87,14 @@ class Validate
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Vérifie si le type est valide.
|
|
|
|
* Vérifie si le type est valide.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param string $type Le type à vérifier.
|
|
|
|
* @param string $type Le type a vérifié.
|
|
|
|
* @return bool Vrai si le type est valide, faux sinon.
|
|
|
|
* @return bool Vrai si le type est valide, faux sinon.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
static function type($type) : bool
|
|
|
|
static function type(string $type) : bool
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $typeMaxLength;
|
|
|
|
global $typeMaxLength;
|
|
|
|
if (isset($type) && strlen($type) <= $typeMaxLength && strlen($type) >=3)
|
|
|
|
if (strlen($type) <= $typeMaxLength && strlen($type) >=3)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
else return false;
|
|
|
|
else return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -102,13 +102,13 @@ class Validate
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Vérifie si la réponse est valide.
|
|
|
|
* Vérifie si la réponse est valide.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param string $response La réponse à vérifier.
|
|
|
|
* @param string $response La réponse a vérifié.
|
|
|
|
* @return bool Vrai si la réponse est valide, faux sinon.
|
|
|
|
* @return bool Vrai si la réponse est valide, faux sinon.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
static function response($response) : bool{
|
|
|
|
static function response(string $response) : bool{
|
|
|
|
global $responseMaxLength;
|
|
|
|
global $responseMaxLength;
|
|
|
|
if(isset($response) && strlen($response) <= $responseMaxLength)
|
|
|
|
if(strlen($response) <= $responseMaxLength)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
else return false;
|
|
|
|
else return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|