> */ public function rules(): array { return [ 'name' => ['required', 'string', 'max:255'], 'pos' => ['nullable', 'integer', 'min:0', 'max:255'], ]; } protected function prepareForValidation(): void { if ($this->has('pos') && $this->input('pos') === '') { $this->merge(['pos' => 0]); } } }