Skip to main content

UserUpdateDTO

Package: @nauth-toolkit/core Type: DTO (Request)

Data transfer object for updating user profile attributes with optional fields and validation.

import { UserUpdateDTO } from '@nauth-toolkit/nestjs';

Properties​

PropertyTypeRequiredDescription
usernamestringNoUsername. 3-255 characters. Alphanumeric, underscores, hyphens only. Trimmed.
firstNamestringNoFirst name. 1-100 characters. Trimmed.
lastNamestringNoLast name. 1-100 characters. Trimmed.
emailstringNoEmail address. Valid email format. Max 255 characters. Trimmed and lowercased.
phonestringNoPhone number. E.164 format (e.g., +14155552671). Max 20 characters. Whitespace removed.
localestringNoBCP 47 locale (e.g. en-GB). Rejected if not a valid tag. Max 35 characters.
metadataRecord<string, unknown>NoCustom metadata fields. Merged with existing metadata. Set key to null to delete.
timezonestringNoIANA timezone (e.g. Europe/Dublin). Rejected if unknown to the runtime. Max 64 chars.
preferredMfaMethodMFADeviceMethodNoPreferred MFA method. Must be: totp, sms, email, passkey. Max 50 characters.

retainVerification is not part of this base DTO. It is an administrator-only field defined on AdminUpdateUserAttributesDto. Self-service email/phone changes always reset the corresponding verification flag.

Metadata Behavior​

The metadata field supports merge and delete operations:

  • Add/Update: Provide key-value pairs to add or update
  • Delete: Set a key to null to remove it from metadata
  • Merge: Existing metadata is preserved unless explicitly updated or deleted

Examples​

Basic Update​

{
"username": "johndoe",
"firstName": "John",
"lastName": "Doe",
"email": "john@example.com",
"phone": "+14155552671",
"preferredMfaMethod": "totp"
}

Adding/Updating Metadata​

{
"metadata": {
"department": "Engineering",
"role": "Senior Developer"
}
}

Deleting Metadata Keys​

{
"metadata": {
"temporaryField": null,
"oldKey": null
}
}

Mixing Metadata Operations​

{
"firstName": "Jane",
"metadata": {
"department": "Product",
"role": "Product Manager",
"oldDepartment": null
}
}

Used By​