laracasts / Validation

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

Update validators #10

Open elstamey opened 10 years ago

elstamey commented 10 years ago

In the laracasts demonstration, there was never any situation that used the validators to update, and I could really use some help with validating uniqueness except on update. Could you provide an example in the README or add a Laracast link to something that will help me fix the mess I've created?

arthurkirkosa commented 10 years ago

The update form should be it's own class with it's own set of rules.

if you need to pass the id to check for uniqueness, in your update form class overwrite the

public function getValidationRules();

or add another function that will prepare the $rules (by replacing a string in your rules with the actual id value) and return $this and chain that to the form before calling the validate() method.

schulzefelix commented 10 years ago

You should look at https://github.com/laracasts/Validation/issues/6