Validation
Unless you like to live dangerously, any Nova fields that are displayed on the Nova creation / update screens will need some validation. Thankfully, it's a cinch to attach all of the Laravel validation rules you're familiar with to your Nova resource fields. Let's get started.
اضافه کردن قانون
Text::make('Name')
->rules('required', 'max:255'),
use App\Rules\ValidState;
Text::make('State')
->rules('required', new ValidState),
Text::make('State')
->rules('required', function($attribute, $value, $fail) {
if (strtoupper($value) !== $value) {
return $fail('The '.$attribute.' field must be uppercase.');
}
})