diff --git a/public_html/includes/class/class.LSformRule_callable.php b/public_html/includes/class/class.LSformRule_callable.php new file mode 100644 index 00000000..ee92655e --- /dev/null +++ b/public_html/includes/class/class.LSformRule_callable.php @@ -0,0 +1,63 @@ + + */ +class LSformRule_callable extends LSformRule { + + /** + * Check the value using the callable object + * + * @param mixed $value The value to check + * @param array $options Validation option + * - callable : the function use to check the value + * + * The callable object will be run to check the value. The given parameters are the + * same of this method. + * + * @param object $formElement The LSformElement object + * + * @return boolean true if the value is valid, false otherwise + */ + function validate($value,$option,$formElement) { + if (is_callable($option['callable'])) { + return call_user_func($option['callable'],$value,$option,$formElement); + } + else { + LSerror :: addErrorCode('LSformRule_callable_01'); + return False; + } + } + +} + +/* + * Error codes + */ +LSerror :: defineError('LSformRule_callable_01', +_("LSformRule_callable : The given callable option is not callable") +); + +?>