src/Valitron/Validator.php
/**
     * Run validations and return boolean result
     *
     * @return boolean
     */
Run validations and return boolean result
@return boolean
Run validations and return boolean result @return boolean
public function validate()
    {
        foreach($this->_validations as $v) {
            foreach($v['fields'] as $field) {
                $value = isset($this->_fields[$field]) ? $this->_fields[$field] : null;
                if ($v['rule'] !== 'required' && !$this->hasRule('required', $field) && $value == '') {
                    continue;
                }
                if(isset(static::$_rules[$v['rule']])) {
                    $callback = static::$_rules[$v['rule']];
                } else {
                    $callback = array($this, 'validate' . ucfirst($v['rule']));
                }
                $result = call_user_func($callback, $field, $value, $v['params']);
                if(!$result) {
                    $this->error($field, $v['message'], $v['params']);
                }
            }
        }
        return count($this->errors()) === 0;
    }
public function validate ( ) { foreach ( $ this -> _validations as $ v ) { foreach ( $ v [ 'fields' ] as $ field ) { $ value = isset ( $ this -> _fields [ $ field ] ) ? $ this -> _fields [ $ field ] : null ; if ( $ v [ 'rule' ] !== 'required' && ! $ this -> hasRule ( 'required' , $ field ) && $ value == '' ) { continue ; } if ( isset ( static :: $ _rules [ $ v [ 'rule' ] ] ) ) { $ callback = static :: $ _rules [ $ v [ 'rule' ] ] ; } else { $ callback = array ( $ this , 'validate' . ucfirst ( $ v [ 'rule' ] ) ) ; } $ result = call_user_func ( $ callback , $ field , $ value , $ v [ 'params' ] ) ; if ( ! $ result ) { $ this -> error ( $ field , $ v [ 'message' ] , $ v [ 'params' ] ) ; } } } return count ( $ this -> errors ( ) ) === 0 ; }
Run validations and return boolean result
 @return boolean
Run validations and return boolean result @return boolean
// Don't validate if the field is not required and the value is empty // Callback is user-specified or assumed method on class