Validation
Last updated
Last updated
Voyager allows you to dynamically add validation rules to all formfields in a view.
To start open the options for a formfield and look for the Validation
section.
Click the +
button to add a rule and fill in the Rule
and the Message
which will be displayed when this rule fails. The message field is translatable to display translated error messages to users.
Please check the Laravel documentation for all available validation rules.
You can validate the current app locale or all locales by setting the option to Validate all locales
or Validate current locale
in the layout options.
With this you can use Voyager::setLocales([...])
to dynamically set languages for various users.
For example user A speaks english and german, you could run
in your service provider and select Validate all locales
to force the user to enter the data in both his languages.
When Validate current locale
is selected, only the current locale is validated. Other entered languages are ignored.
Given then following array:
you can validate any fields by using .name:required
or .email:email
respectively.
Please notice the leading .
which tells Voyager that you want to validate a 1-dimensional array
Given the following array of users:
You can validate any fields in all elements (users in this case) by using *.name:required
and *.email:email
.
Please notice the leading *.
which tells Voyager that you want to validate a multi-dimensional array