['required', 'max:255'], 'email' => ['required', 'email', 'max:255'], 'is_active' => ['required', 'boolean'], 'roles' => ['array', Rule::exists('roles', 'id')], ]; if ($this->getMethod() === 'POST') { $rules['password'] = ['required', Password::default()]; } return $rules; } public function getDto(): StoreUpdate { return new StoreUpdate( name: $this->input('name'), email: $this->input('email'), isActive: (bool) $this->input('is_active', false), roles: new ManyRoleDto($this->input('roles', [])), password: $this->input('password', null), ); } }