Skip to content

Generators

Validatable classes can be generated using the Artisan command below.

bash
# Generate a class named UserValidation
php artisan make:validation UserValidation
bash
# Generate a class named UserValidation and overwrite a possible existing file
php artisan make:validation UserValidation --force

Default stub

By default, the command creates a class that looks as follows.

php
<?php

declare(strict_types=1);

namespace App\Validation;

use LaraPkgs\Validation\Validatable;
use LaraPkgs\Validation\ValidatableCollection;

final class UserValidation extends Validatable
{
    protected function makeValidatableCollection(): ValidatableCollection
    {
        return ValidatableCollection::make(
            //
        );
    }
}

Publishing the stub

If needed, the stub file can be published and adjusted as needed.

bash
php artisan vendor:publish --tag=larapkgs-validation-stubs

Configure behavior

The behavior of the generator can be configured using the generators.validation section in the configuration file. More information about configuring the package can be found here.