corps de la fonction checkParam

This commit is contained in:
Clecle 2015-11-11 08:05:51 +01:00
parent 989cae3b32
commit 3a5c1ee9ad
1 changed files with 21 additions and 2 deletions

View File

@ -153,7 +153,7 @@
/* [1] Vérification de l'intégrité des tableaux /* [1] Vérification de l'intégrité des tableaux
=============================================================================*/ =============================================================================*/
$areArrays = is_array($tabVar) && is_array($tabForm); // si ce sont bien des tabeaux $areArrays = is_array($tabVar) && is_array($tabForm); // si ce sont bien des tabeaux
$areNEmpty = $areArrays && count($tabVar) > 0 && count($tabVar) > 0; // si ils ne sont pas vides $areNEmpty = $areArrays && count($tabVar) > 0 && count($tabForm) > 0; // si ils ne sont pas vides
$haveEqLen = $areNEmpty && count($tabVar) == count($tabForm); // si ils ont la même taille $haveEqLen = $areNEmpty && count($tabVar) == count($tabForm); // si ils ont la même taille
if( !$haveEqLen ) // si toutes les conditions ne sont pas vérifiées if( !$haveEqLen ) // si toutes les conditions ne sont pas vérifiées
@ -164,10 +164,29 @@
=============================================================================*/ =============================================================================*/
$checker = true; // on définit le checker à VRAI $checker = true; // on définit le checker à VRAI
// Vérification des types
// pour chaque variable // pour chaque variable
foreach ($tabVar as $type => $value){ foreach ($tabVar as $type => $tabVal){
foreach($tabVal as $variable) { // <--- Gestion des tableaux de valeurs ???
$checker = ($type == gettype($variable));
if($checker == false)
return (" variable : ".(String)$variable." non conforme, type attendu : ".(String)$type." type reçu :".gettype($variable));
}
} }
// Vérification des formats
foreach($tabForm as $format => $tabVal) {
foreach ($tabVal as $variable) { // <--- Gestion des tableaux de valeurs ???
$checker = preg_match($format,$variable);
if($checker == false)
return (" variable : ".$variable." non conforme, format attendu : ".(String)$format." format reçu :".(String)$variable);
}
}
return $checker;
} }
?> ?>