Example #1
0
 function validateEntry($value)
 {
     $config = $this->getConfiguration();
     parent::validateEntry($value);
     if (!$value) {
         return;
     }
     if ($config['min'] and $value < $config['min']) {
         $this->_errors[] = 'Selected date is earlier than permitted';
     } elseif ($config['max'] and $value > $config['max']) {
         $this->_errors[] = 'Selected date is later than permitted';
     } elseif ($value === -1 or $value === false) {
         $this->_errors[] = 'Enter a valid date';
     }
 }
Example #2
0
 function validateEntry($value)
 {
     parent::validateEntry($value);
     $config = $this->getConfiguration();
     # Run validator against $this->value for email type
     list($phone, $ext) = explode("X", $value, 2);
     if ($phone && (!is_numeric($phone) || strlen($phone) < $config['digits'])) {
         $this->_errors[] = "Enter a valid phone number";
     }
     if ($ext && $config['ext']) {
         if (!is_numeric($ext)) {
             $this->_errors[] = "Enter a valid phone extension";
         } elseif (!$phone) {
             $this->_errors[] = "Enter a phone number for the extension";
         }
     }
 }
Example #3
0
 function validateEntry($value)
 {
     parent::validateEntry($value);
     $config = $this->getConfiguration();
     $validators = array('' => null, 'email' => array(array('Validator', 'is_email'), 'Enter a valid email address'), 'phone' => array(array('Validator', 'is_phone'), 'Enter a valid phone number'), 'ip' => array(array('Validator', 'is_ip'), 'Enter a valid IP address'), 'number' => array('is_numeric', 'Enter a number'));
     // Support configuration forms, as well as GUI-based form fields
     $valid = $this->get('validator');
     if (!$valid) {
         $valid = $config['validator'];
     }
     if (!$value || !isset($validators[$valid])) {
         return;
     }
     $func = $validators[$valid];
     $error = $func[1];
     if ($config['validator-error']) {
         $error = $config['validator-error'];
     }
     if (is_array($func) && is_callable($func[0])) {
         if (!call_user_func($func[0], $value)) {
             $this->_errors[] = $error;
         }
     }
 }