Field Validation

Fields that are not validated entail security risks, any values can be stored for all fillable attributes without validation. It is therefore highly recommended to append validation rules to any field that handles a fillable attribute. The Laravel documentation describes all existing rules that can be used for request validation.

Attach Rules

The following example shows how the rules are attached to a field:

$form->input('text')
    ->title('Text')
    ->rules('required', 'min:10', 'max:50');

The error messages are displayed directly below the field. The title is displayed as attribute.

Field Validation

Update Rules

All rules specified via the method rules apply to the creation and updating of a model. Rules that should only apply for updating a model are defined in updateRules like this:

$form->input('text')
    ->title('Text')
    ->rules('min:10')
    ->updateRules('max:50');

Creation Rules

Similarly, rules can be specified only for creating a model.

$form->input('text')
    ->title('Text')
    ->rules('min:10', 'max:50')
    ->creationRules('required');
Join us on our discord server