Open r-shaygan opened 1 year ago
It accepts an array of rules too, Laravel-like. So something like:
$form->text('seo_slug', __('SEO slug'))->rules([
'min:3',
new Slug(), // <-- custom validation rule
'unique:pages,seo_slug',
]);
It accepts an array of rules too, Laravel-like. So something like:
$form->text('seo_slug', __('SEO slug'))->rules([ 'min:3', new Slug(), // <-- custom validation rule 'unique:pages,seo_slug', ]);
I know it accepts an array but every element of the array should return a string of predefined rules.
in your example, what does the method of Slug return??
can you write a closure rule as an example?
new Slug()
returns a new instance of Validation Rule extended class, as described by Laravel docs of the version you use. I was using docs 8.x example.
by Encore\Admin\Form\Field::rules method, we can just pass a string or closure that returns a string of predefined rules. but I need to create my own rules as a closure (like laravel does)