Skip to Content

@ApiPropertyUUID

Describes UUID-based DTO fields and enforces RFC 4122 validation. Supports single identifiers or arrays with uniqueness constraints.

Signature

@ApiPropertyUUID(properties: TApiPropertyUuidProperties)

Options

OptionDescription
descriptionDefaults to "identifier" if omitted; appended to the entity name.
isArray, minItems, maxItems, isUniqueItemsEnables arrays of UUIDs with full validation.
isRequired, isNullable, isResponse, isExposeStandard property flags.

Behavior

  • Generates a random UUID example for Swagger and sets the appropriate regex pattern/length.
  • Adds IsUUID, IsOptional, IsArray, ArrayMinSize, ArrayMaxSize, and ArrayNotEmpty as needed.
  • Marks the Swagger schema with format: uuid and sets example or [example] for arrays.
  • Adds ApiResponseProperty, Expose, or Exclude for response DTOs.

Example

class BulkDeleteDto { @ApiPropertyUUID({ entity: () => UserEntity, description: "IDs to remove", isArray: true, minItems: 1, maxItems: 50, isUniqueItems: true, }) ids!: Array<string>; }
Last updated on