$val->add('password', 'Password') ->add_rule('required') ->add_rule('min_length', 3) ->add_rule('max_length', 20) ->add_rule(function($val) { return $val == 'test'? true:false; } );
public function __construct($field, $value, $callback, $params) { $this->field = $field; $this->value = $value; $this->params = $params; /** * Simplify callback for rule, class/object and method are seperated by 1 colon * and objects become their classname without the namespace. * Rules called on a callable are considered without classname & method prefix */ if (is_array($callback)) { foreach ($field->fieldset()->validation()->callables() as $c) { if ($c == $callback[0] && substr($callback[1], 0, 12) == '_validation_') { $callback = substr($callback[1], 12); break; } } } $this->callback = is_string($callback) ? str_replace('::', ':', $callback) : preg_replace('#^([a-z_]*\\\\)*#i', '', get_class($callback[0])).':'.$callback[1]; // ERROR IS IN THIS LINE }
It looks like you're new here. If you want to get involved, click one of these buttons!