UserUpdateDTO
Package: @nauth-toolkit/core
Type: DTO (Request)
Data transfer object for updating user profile attributes with optional fields and validation.
- NestJS
- Express
- Fastify
import { UserUpdateDTO } from '@nauth-toolkit/nestjs';
import { UserUpdateDTO } from '@nauth-toolkit/core';
import { UserUpdateDTO } from '@nauth-toolkit/core';
Properties
| Property | Type | Required | Description |
|---|---|---|---|
username | string | No | Username. 3-255 characters. Alphanumeric, underscores, hyphens only. Trimmed. |
firstName | string | No | First name. 1-100 characters. Trimmed. |
lastName | string | No | Last name. 1-100 characters. Trimmed. |
email | string | No | Email address. Valid email format. Max 255 characters. Trimmed and lowercased. |
phone | string | No | Phone number. E.164 format (e.g., +14155552671). Max 20 characters. Whitespace removed. |
metadata | Record<string, unknown> | No | Custom metadata fields. Merged with existing metadata. Set key to null to delete. |
preferredMfaMethod | MFADeviceMethod | No | Preferred MFA method. Must be: totp, sms, email, passkey. Max 50 characters. |
retainVerification | boolean | No | Retain 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
nullto 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
- UpdateUserAttributesDTO - Extends this DTO
- AdminUpdateUserAttributesDTO - Extends this DTO (admin)
- AuthService.updateUserAttributes()