['required', 'max:255'], 'permissions' => ['array', new Permission()] ]; if ($this->getMethod() === 'POST') { $rules['code'] = ['required', 'min:3', 'max:255', 'regex:/^[a-z0-9_-]+$/i']; } return $rules; } public function getDto(): StoreUpdate { return new StoreUpdate( name: $this->input('name'), code: $this->input('code', null), permissions: $this->input('permissions', []) ); } }