public function validateOrFail(array $data, $model=null)
    {

        $this->publish('validating', [$this, $data, $model]);

        $rules = $this->rules();

        $parsedRules = $this->parseRules($rules, $data, $model);

        $this->publish('validation-rules.parsed', [&$parsedRules]);

        $validator = $this->getValidatorInstance($parsedRules, $data, $model);
        $validator->setAttributeNames($this->customAttributes());

        if ($this->validate($validator)) {
            return true;
        }

        throw new \Illuminate\Validation\ValidationException($validator);

    }
public function validateOrFail(array $data, $model=null)
    {

        $this->publish('validating', [$this, $data, $model]);

        $rules = $this->rules();

        $parsedRules = $this->parseRules($rules, $data, $model);

        $this->publish('validation-rules.parsed', [&$parsedRules]);

        $validator = $this->getValidatorInstance($parsedRules, $data, $model);
        $validator->setAttributeNames($this->customAttributes());

        if ($this->validate($validator)) {
            return true;
        }

        throw new \Illuminate\Validation\ValidationException($validator);

    }
public function validateOrFail ( array $ data , $ model = null ) { $ this -> publish ( 'validating' , [ $ this , $ data , $ model ] ) ; $ rules = $ this -> rules ( ) ; $ parsedRules = $ this -> parseRules ( $ rules , $ data , $ model ) ; $ this -> publish ( 'validation-rules.parsed' , [ & $ parsedRules ] ) ; $ validator = $ this -> getValidatorInstance ( $ parsedRules , $ data , $ model ) ; $ validator -> setAttributeNames ( $ this -> customAttributes ( ) ) ; if ( $ this -> validate ( $ validator ) ) { return true ; } throw new \ Illuminate \ Validation \ ValidationException ( $ validator ) ; }
Validate the data. If validation failes, throw a exception
If a model is passed as the second parameter, parse the rules
to match the model. If no model is passed, considerate it as
a new model

@param array $data The (request) data
@param mixed $model (optional)
@return bool
@throw \Illuminate\Contracts\Validation\ValidationException
Validate the data . If validation failes throw a exception If a model is passed as the second parameter parse the rules to match the model . If no model is passed considerate it as a new model