Présentation
Ce validateur vérifie que la valeur donnée est une chaine de caractères.
Il est possible de lui demander de contrôler d'autres éléments sur le tableau, a savoir :
- Si elle contient une sous chaine (contains)
- Si elle ne dépasse pas un certain nombre de caractères (maxLength)
- Si elle dépasse un certain nombre de caractères (minLength)
Exemple d'utilisation
<?php _validator ('string')->check ('Chaine');//ok _validator ('string')->check (array ());//PAS ok _validator ('string')->check (null);//PAS ok ?>
Exemples avec d'autres options
<?php //Vérifie que la chaine contient la sous chaine Copix _validator ('string', array ('contains'=>'Copix'))->check ('Copix est fait pour vous');//ok _validator ('string', array ('contains'=>'Copix'))->check ('Un autre framework est fait pour vous');//PAS ok //Vérifie que la chaine ne dépasse pas une taille maximale _validator ('string', array ('maxLength'=>6))->check ('Copix');//ok _validator ('string', array ('maxLength'=>5))->check ('Copix3');//ok _validator ('string', array ('maxLength'=>4))->check ('Copix');//PAS ok //Vérifie que la chaine est d'une taille minimale _validator ('string', array ('minLength'=>2))->check ('');//PAS ok _validator ('string', array ('minLength'=>2))->check ('ok');//ok _validator ('string', array ('minLength'=>2))->check ('oki');//ok ?>
