Last active
December 20, 2016 14:50
-
-
Save MarkVaughn/eb487a72227236e0f26b50a39d50a062 to your computer and use it in GitHub Desktop.
Assert Valid
This file contains 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
/** | |
* Asserts a single value passes on one ore many laravel validation rules. | |
* | |
* @param array|string $rule | |
* @param mixed $value | |
*/ | |
protected function assertValid($rule, $value) | |
{ | |
$rules = [ | |
'test' => (array) $rule, | |
]; | |
$data = [ | |
'test' => $value, | |
]; | |
$this->assertTrue( | |
Validator::make($data, $rules)->passes(), | |
sprintf( | |
'Failed validating "%s"" passes rule(s): %s ', | |
print_r($value, true), | |
json_encode($rules, true) | |
) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment