|string> */ public function rules(): array { $rules = [ 'name' => ['required', 'string', 'max:255'], 'email' => [ 'required', 'string', 'lowercase', 'email', 'max:255', Rule::unique(User::class)->ignore($this->user()?->id), ], // Saved with the rest of the profile so the screen keeps one // Save button. `timezone` is fillable, so ProfileController's // fill() picks it up with no special handling. // // `sometimes`, not `required`: the form always sends it, but a // caller that doesn't should leave the stored zone alone // rather than be rejected — and there is no "no timezone" to // clear it to. 'timezone' => ['sometimes', ...Rules::timezone()], ]; $user = $this->user(); if ($user?->isClient() === true) { $rules = [ ...$rules, ...app(ClientPortalCustomFields::class)->rules(ClientFieldContext::AccountEdit, $user), ]; } return $rules; } }