Skip to content

Instantly share code, notes, and snippets.

@MarkVaughn
Last active December 20, 2016 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarkVaughn/eb487a72227236e0f26b50a39d50a062 to your computer and use it in GitHub Desktop.
Save MarkVaughn/eb487a72227236e0f26b50a39d50a062 to your computer and use it in GitHub Desktop.
Assert Valid
/**
* 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