laracasts / Validation

Easy form validation.
https://packagist.org/packages/laracasts/validation
MIT License
150 stars 37 forks source link

The Validate Method #11

Open clevonnoel opened 10 years ago

clevonnoel commented 10 years ago

It would be nice to handle validation like $this->registrationForm->validate();where necessary.

Here are the untested suggested code.

    public function validate(array $formData = null)
    {
        $this->validation = $this->validator->make(
            $formData ?: Input::all(),
            $this->getValidationRules(),
            $this->getValidationMessages()
        );

        if ($this->validation->fails())
        {
            throw new FormValidationException('Validation failed', $this->getValidationErrors());
        }

        return true;
    }
JacobBennett commented 9 years ago

Submit a pull request