Validation

Any fields that are displayed on the Lamotivo creation or update forms will need some validation. Lamotivo uses the internal Laravel validation rules.

Attaching Rules

When defining a field on a resource, you may use the rules method to attach validation rules to the field:

Text::make('name')
    ->rules('required'),

Alternatively, validation rules may be specified as arrays of rules instead of a single string:

Text::make('email')
    ->rules([
        'required',
        'email',
    ]),

Custom Error Messages

Lamotivo uses the default error messages for validation. If you need, you may use the messages method to define custom error messages:

Text::make('name')
    ->rules('required')
    ->messages([
        'required' => 'You should provide a value',
    ]),