@ApiPropertyUUID
Describes UUID-based DTO fields and enforces RFC 4122 validation. Supports single identifiers or arrays with uniqueness constraints.
Signature
@ApiPropertyUUID(properties: TApiPropertyUuidProperties)Options
| Option | Description |
|---|---|
description | Defaults to "identifier" if omitted; appended to the entity name. |
isArray, minItems, maxItems, isUniqueItems | Enables arrays of UUIDs with full validation. |
isRequired, isNullable, isResponse, isExpose | Standard property flags. |
Behavior
- Generates a random UUID example for Swagger and sets the appropriate regex pattern/length.
- Adds
IsUUID,IsOptional,IsArray,ArrayMinSize,ArrayMaxSize, andArrayNotEmptyas needed. - Marks the Swagger schema with
format: uuidand setsexampleor[example]for arrays. - Adds
ApiResponseProperty,Expose, orExcludefor response DTOs.
Example
class BulkDeleteDto {
@ApiPropertyUUID({
entity: () => UserEntity,
description: "IDs to remove",
isArray: true,
minItems: 1,
maxItems: 50,
isUniqueItems: true,
})
ids!: Array<string>;
}Related resources
Last updated on