*/ class LSformRule_regex extends LSformRule { /** * Vérification de la valeur. * * @param string $values Valeur à vérifier * @param array $options Options de validation : * - Regex : $option['params']['regex'] ou $option * @param object $formElement L'objet formElement attaché * * @return boolean true si la valeur est valide, false sinon */ function validate($value,$option,$formElement) { if (is_array($option)) { if (isset($option['params']['regex'])) { $regex=$option['params']['regex']; } else { LSerror::addErrorCode('LSformRule_regex_01'); return; } } else { $regex=$option; } if (!preg_match($regex, $value)) { return false; } return true; } } /* * Error Codes */ $GLOBALS['LSerror_code']['LSformRule_regex_01'] = array( 'msg' => _("LSformRule_regex : Regex has not been configured to validate data.") ); ?>