8000 Add validator helper · laravel/lumen-framework@029df5b · GitHub
[go: up one dir, main page]

Skip to content

Commit 029df5b

Browse files
committed
Add validator helper
1 parent 0e438d9 commit 029df5b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/helpers.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,28 @@ function url($path = null, $parameters = [], $secure = null)
358358
}
359359
}
360360

361+
if (! function_exists('validator')) {
362+
/**
363+
* Create a new Validator instance.
364+
*
365+
* @param array $data
366+
* @param array $rules
367+
* @param array $messages
368+
* @param array $customAttributes
369+
* @return \Illuminate\Contracts\Validation\Validator
370+
*/
371+
function validator(array $data = [], array $rules = [], array $messages = [], array $customAttributes = [])
372+
{
373+
$factory = app('validator');
374+
375+
if (func_num_args() === 0) {
376+
return $factory;
377+
}
378+
379+
return $factory->make($data, $rules, $messages, $customAttributes);
380+
}
381+
}
382+
361383
if (! function_exists('view')) {
362384
/**
363385
* Get the evaluated view contents for the given view.

0 commit comments

Comments
 (0)
0