Last active
November 23, 2016 05:42
-
-
Save nmfzone/050d948ab9d10c1ddfec04981b568f65 to your computer and use it in GitHub Desktop.
Custom Validation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Validator::extend('different_if_present', function($attribute, $value, $parameters, $validator) { | |
| $otherValue = Arr::get($validator->getData(), $parameters[0]); | |
| return $value !== $otherValue; | |
| }); | |
| Validator::replacer('different_if_present', function($message, $attribute, $rule, $parameters) { | |
| return str_replace(':other', $parameters[0], $message); | |
| }); | |
| // How to use | |
| 'address1' => 'required|different_if_present:address2', | |
| 'address2' => 'different_if_present:address1', |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment