Example #1
0
 /**
  * Check all registered rules
  *
  * @return bool
  */
 public function check()
 {
     if (!empty($this->options['rules'])) {
         foreach ($this->options['rules'] as $index => $name) {
             $rule_name = is_array($name) ? $index : $name;
             $rule_options = is_array($name) ? $name : [];
             $rule = new Rule($rule_name, $this->value, $rule_options);
             if (!$rule->check()) {
                 $real_name = explode(':', $rule_name);
                 $this->error = !empty($this->options['messages'][$real_name[0]]) ? $this->options['messages'][$real_name[0]] : $rule->getError();
             }
         }
     }
     return empty($this->error);
 }
Example #2
0
 /**
  * Returns true if the rule is valid for the given context
  *
  * @param mixed $context
  *
  * @return boolean
  */
 public function isValid($context)
 {
     return $this->rule->check($context);
 }