-
-
Notifications
You must be signed in to change notification settings - Fork 175
Facade
albertmoreno edited this page Mar 4, 2016
·
18 revisions
The Laravel Javascript Jalidation package comes with a handy Facade to make creating and rendering your validators easily.
Creates JsValidator instance based on rules and message arrays.
JsValidator::make($rules, $messages, $customAttributes, $selector)
-
$rules
(array) Validation rules using the Laravel Validation Rules syntax. used. Required -
$messages
(array) Messages showed when validation fails. Optional, if empty default localized laravel messages are used. -
$customAttributes
(array) Custom attribute names. Optional -
$selector
(string) JQuery selector to select the HTML form to be validated. Optional, by default value defined in Configuration will be used.
- \Proengsoft\JsValidation\JsValidator instance
$validator = JsValidator::make(
[
'name' => 'Dayle',
'password' => 'lamepassword',
'email' => '[email protected]'
],
[
'name' => 'required',
'password' => 'required|min:8',
'email' => 'required|email|unique:users'
],
[],
'#user-form'
)
Creates JsValidator instance based on FormRequest.
JsValidator::formRequest($formRequest, $selector)
-
$formRequest
(Illuminate\Foundation\Http\FormRequest|string) Form Request name or instance with validations. -
$selector
(string) JQuery selector to select the HTML form to be validated. Optional, by defaultform
will be used.
- \Proengsoft\JsValidation\JsValidator instance
$validator = JsValidator::formRequest(
'App\Http\Requests\StoreBlogPostRequest',
'#post-form'
);
Creates JsValidator instance based on Validator instance.
JsValidator::validator(\Illuminate\Contracts\Validation\Validator $validator, null $selector)
-
$validator
(Illuminate\Contracts\Validation\Validator) -
$selector
(string) JQuery selector to select the HTML form to be validated. Optional, by defaultform
will be used.
- \Proengsoft\JsValidation\JsValidator instance
$validator = Validator::make(
['name' => 'Dayle'],
['name' => 'required|min:5']
);
// ....
$jsval = JsValidator::validator($validator);