Skip to content

Support custom validation rules via classes #17

@simonrjones

Description

@simonrjones

Custom packages in Laravel can have validation rules, which are called via a class. This does not currently work in the Form builder.

E.g. in app/Forms/BookRequestForm.php

        ->add('isbn', TextType::class, [
            'label' => 'ISBN',
            'rules' => ['required', new Isbn([13])]
        ])

This does work, which is only OK since a shortcode has been setup for this rule. This may not always exist in custom validation rules.

        ->add('isbn', TextType::class, [
            'label' => 'ISBN',
            'rules' => ['required', 'isbn:13']
        ])

See https://laravel.com/docs/13.x/validation#custom-validation-rules

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions