src/Titon/Model/Model.php
public function validate() {
        $this->_errors = [];

        // No rules
        if (!$this->validate) {
            return true;
        }

        // Build the validator
        $validator = $this->getValidator();
        $validator->reset();
        $validator->addMessages($this->messages);
        $validator->setData($this->toArray());

        $event = $this->emit('model.preValidate', [$this, $validator]);

        // Exit early if event has returned false
        if ($event->getData() === false) {
            return false;
        }

        $status = $validator->validate();

        $this->_errors = $validator->getErrors();
        $this->_validator = null;

        $this->emit('model.postValidate', [$this, $status]);

        return $status;
    }
public function validate() {
        $this->_errors = [];

        // No rules
        if (!$this->validate) {
            return true;
        }

        // Build the validator
        $validator = $this->getValidator();
        $validator->reset();
        $validator->addMessages($this->messages);
        $validator->setData($this->toArray());

        $event = $this->emit('model.preValidate', [$this, $validator]);

        // Exit early if event has returned false
        if ($event->getData() === false) {
            return false;
        }

        $status = $validator->validate();

        $this->_errors = $validator->getErrors();
        $this->_validator = null;

        $this->emit('model.postValidate', [$this, $status]);

        return $status;
    }
public function validate ( ) { $ this -> _errors = [ ] ; // No rules if ( ! $ this -> validate ) { return true ; } // Build the validator $ validator = $ this -> getValidator ( ) ; $ validator -> reset ( ) ; $ validator -> addMessages ( $ this -> messages ) ; $ validator -> setData ( $ this -> toArray ( ) ) ; $ event = $ this -> emit ( 'model.preValidate' , [ $ this , $ validator ] ) ; // Exit early if event has returned false if ( $ event -> getData ( ) === false ) { return false ; } $ status = $ validator -> validate ( ) ; $ this -> _errors = $ validator -> getErrors ( ) ; $ this -> _validator = null ; $ this -> emit ( 'model.postValidate' , [ $ this , $ status ] ) ; return $ status ; }
Validate the current set of data against the models validation rules.

@return bool
Validate the current set of data against the models validation rules .