src/Util/Validator.php
public function validate()
    {
        $setToBreak = false;

        foreach ($this->_validations as $v) {
            foreach ($v['fields'] as $field) {
                if (isset($this->_skips[$field])) {
                    if ($this->_skips[$field] === self::SKIP_ALL) {
                        break 2;
                    }

                    if ($this->_skips[$field] === self::SKIP_ONE) {
                        break;
                    }
                }

                [$values, $multiple] = $this->getPart($this->_fields, \explode('.', $field));

                // Don't validate if the field is not required and the value is empty
                if (null !== $values && $this->hasRule('optional', $field)) {
                    //Continue with execution below if statement
                } elseif (
                    $v['rule'] !== 'accepted' &&
                    $v['rule'] !== 'required' && !$this->hasRule('required', $field) &&
                    (null === $values || $values === '' || ($multiple && \count($values) === 0))
                ) {
                    continue;
                }

                // Callback is user-specified or assumed method on class
                $errors = $this->getRules();
                if (isset($errors[$v['rule']])) {
                    $callback = $errors[$v['rule']];
                } else {
                    $callback = [$this, 'validate' . \ucfirst($v['rule'])];
                }

                if (!$multiple) {
                    $values = [$values];
                }

                $result = true;
                foreach ($values as $value) {
                    $result = $result && $callback($field, $value, $v['params'], $this->_fields);
                }

                if (!$result) {
                    $this->error($field, $v['message'], $v['params']);
                    if ($this->stopOnFirstFail) {
                        $setToBreak = true;
                        break;
                    }
                    $this->_skips[$field] = $v['skip'];
                }
            }

            if ($setToBreak) {
                break;
            }
        }

        return \count($this->errors()) === 0;
    }
public function validate()
    {
        $setToBreak = false;

        foreach ($this->_validations as $v) {
            foreach ($v['fields'] as $field) {
                if (isset($this->_skips[$field])) {
                    if ($this->_skips[$field] === self::SKIP_ALL) {
                        break 2;
                    }

                    if ($this->_skips[$field] === self::SKIP_ONE) {
                        break;
                    }
                }

                [$values, $multiple] = $this->getPart($this->_fields, \explode('.', $field));

                // Don't validate if the field is not required and the value is empty
                if (null !== $values && $this->hasRule('optional', $field)) {
                    //Continue with execution below if statement
                } elseif (
                    $v['rule'] !== 'accepted' &&
                    $v['rule'] !== 'required' && !$this->hasRule('required', $field) &&
                    (null === $values || $values === '' || ($multiple && \count($values) === 0))
                ) {
                    continue;
                }

                // Callback is user-specified or assumed method on class
                $errors = $this->getRules();
                if (isset($errors[$v['rule']])) {
                    $callback = $errors[$v['rule']];
                } else {
                    $callback = [$this, 'validate' . \ucfirst($v['rule'])];
                }

                if (!$multiple) {
                    $values = [$values];
                }

                $result = true;
                foreach ($values as $value) {
                    $result = $result && $callback($field, $value, $v['params'], $this->_fields);
                }

                if (!$result) {
                    $this->error($field, $v['message'], $v['params']);
                    if ($this->stopOnFirstFail) {
                        $setToBreak = true;
                        break;
                    }
                    $this->_skips[$field] = $v['skip'];
                }
            }

            if ($setToBreak) {
                break;
            }
        }

        return \count($this->errors()) === 0;
    }
public function validate ( ) { $ setToBreak = false ; foreach ( $ this -> _validations as $ v ) { foreach ( $ v [ 'fields' ] as $ field ) { if ( isset ( $ this -> _skips [ $ field ] ) ) { if ( $ this -> _skips [ $ field ] === self :: SKIP_ALL ) { break 2 ; } if ( $ this -> _skips [ $ field ] === self :: SKIP_ONE ) { break ; } } [ $ values , $ multiple ] = $ this -> getPart ( $ this -> _fields , \ explode ( '.' , $ field ) ) ; // Don't validate if the field is not required and the value is empty if ( null !== $ values && $ this -> hasRule ( 'optional' , $ field ) ) { //Continue with execution below if statement } elseif ( $ v [ 'rule' ] !== 'accepted' && $ v [ 'rule' ] !== 'required' && ! $ this -> hasRule ( 'required' , $ field ) && ( null === $ values || $ values === '' || ( $ multiple && \ count ( $ values ) === 0 ) ) ) { continue ; } // Callback is user-specified or assumed method on class $ errors = $ this -> getRules ( ) ; if ( isset ( $ errors [ $ v [ 'rule' ] ] ) ) { $ callback = $ errors [ $ v [ 'rule' ] ] ; } else { $ callback = [ $ this , 'validate' . \ ucfirst ( $ v [ 'rule' ] ) ] ; } if ( ! $ multiple ) { $ values = [ $ values ] ; } $ result = true ; foreach ( $ values as $ value ) { $ result = $ result && $ callback ( $ field , $ value , $ v [ 'params' ] , $ this -> _fields ) ; } if ( ! $ result ) { $ this -> error ( $ field , $ v [ 'message' ] , $ v [ 'params' ] ) ; if ( $ this -> stopOnFirstFail ) { $ setToBreak = true ; break ; } $ this -> _skips [ $ field ] = $ v [ 'skip' ] ; } } if ( $ setToBreak ) { break ; } } return \ count ( $ this -> errors ( ) ) === 0 ; }
Run validations and return boolean result

@return bool
Run validations and return boolean result