4 if (!defined("_ECRIRE_INC_VERSION")) return;
7 * Vérifier une taille minimale/maximale, pour un mot de passe par exemple
9 * @param string $valeur
10 * La valeur à vérifier.
11 * @param array $options
12 * Les éléments à vérifier (min, max, egal).
14 * Retourne une chaine vide si c'est valide, sinon une chaine expliquant l'erreur.
17 function verifier_taille_dist($valeur, $options=array()){
19 if (!is_string($valeur))
20 return _T('erreur_inconnue_generique');
24 if (isset($options['min']))
25 $ok = ($ok and (strlen($valeur) >= $options['min']));
27 if (isset($options['max'])){
28 $ok = ($ok and (strlen($valeur) <= $options['max']));
30 if (isset($options['egal'])){
31 $ok = ($ok and (strlen($valeur) == $options['egal']));
35 if (isset($options['min']) and isset($options['max']))
36 $erreur = _T('verifier:erreur_taille_entre', $options);
37 elseif (isset($options['max']))
38 $erreur = _T('verifier:erreur_taille_max', $options);
39 elseif (isset($options['egal']))
40 $erreur = _T('verifier:erreur_taille_egal', $options);
42 $erreur = _T('verifier:erreur_taille_min', $options);