Skip to content

Commit

Permalink
Add a validate() helper as a shorthand for Validate::make()
Browse files Browse the repository at this point in the history
  • Loading branch information
AdenFraser committed Dec 2, 2015
1 parent 491fdb0 commit f3efd2c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Illuminate/Foundation/helpers.php
Expand Up @@ -761,3 +761,25 @@ function view($view = null, $data = [], $mergeData = [])
return $factory->make($view, $data, $mergeData);
}
}

if (! function_exists('validate')) {
/**
* Create a new Validator instance.
*
* @param array $data
* @param array $rules
* @param array $messages
* @param array $customAttributes
* @return \Illuminate\Contracts\Validation\Validator
*/
function validate(array $data, array $rules, array $messages = [], array $customAttributes = [])
{
$factory = app('Illuminate\Contracts\Validation\Factory');

if (func_num_args() === 0) {
return $factory;
}

return $factory->make($data, $rules, $messages, $customAttributes);
}
}

0 comments on commit f3efd2c

Please sign in to comment.