/** * Validates the input value according to this attribute * * @param InputInterface $input The input to validate * * @return string|true True if its valid, string with the error if not */ public static function validate($input) { $value = $input->val(); //File if ($input->attr('type') === 'file') { $value = isset($value['name']) ? $value['name'] : null; } $attr = str_replace('/', '\\/', $input->attr('pattern')); return empty($attr) || empty($value) || filter_var($value, FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => "/^{$attr}\$/"))) ? true : sprintf(static::$error_message, $attr); }
/** * Validates the input value according to this attribute * * @param InputInterface $input The input to validate * * @return string|true True if its valid, string with the error if not */ public static function validate($input) { $value = $input->val(); //File if ($input->attr('type') === 'file') { $value = isset($value['name']) && !empty($value['size']) ? $value['name'] : null; } $attr = $input->attr('required'); return empty($attr) || !empty($value) || strlen($value) > 0 ? true : sprintf(static::$error_message, $attr); }
/** * Validates the input value according to this attribute * * @param InputInterface $input The input to validate * * @return string|true True if its valid, string with the error if not */ public static function validate($input) { $value = $input->val(); $attr = $input->attr('min'); return strlen($value) === 0 || $value >= $attr ? true : sprintf(static::$error_message, $attr); }
/** * Validates the input value according to this attribute * * @param InputInterface $input The input to validate * * @return string|true True if its valid, string with the error if not */ public static function validate($input) { $value = $input->val(); $attr = $input->attr('maxlength'); return empty($attr) || strlen($value) <= $attr ? true : sprintf(static::$error_message, $attr); }