Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.lunarphp.com/llms.txt

Use this file to discover all available pages before exploring further.

Overview

If you want to add additional validation rules, you can do so by registering in service provider.

Extending Validation Rules

use Lunar\Hub\Http\Livewire\Components\Products\ProductCreate;
use Lunar\Models\Product;

public function boot() {
    ProductCreate::extendValidation([
        'variant.sku' => ['required', 'min:8'],
        'collections' => ['required', 'array', function (Product $product) {
            return function ($attribute, $value, $fail) use (Product $product) {
                // closure validation
                $fail($product->translateAttribute('name') . " validation failed");
            };
        }],
    ]);
}
TypePageClosure parameters
Product\Lunar\Hub\Http\Livewire\Components\Products\ProductCreate
\Lunar\Hub\Http\Livewire\Components\Products\ProductShow
\Lunar\Models\Product $product