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.
metadataRecord<string, unknown>NoCustom metadata fields. Merged with existing metadata. Set key to null to delete.
preferredMfaMethodMFADeviceMethodNoPreferred MFA method. Must be: totp, sms, email, passkey. Max 50 characters.
retainVerificationbooleanNoRetain verification status when updating email/phone. Default: false.

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",
"retainVerification": false
}

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