-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Expand file tree
/
Copy pathcreate-context-request.dto.ts
More file actions
49 lines (46 loc) · 1.56 KB
/
create-context-request.dto.ts
File metadata and controls
49 lines (46 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsValidContextData } from '@novu/application-generic';
import { CONTEXT_IDENTIFIER_REGEX, ContextData, ContextId, ContextType } from '@novu/shared';
import { IsDefined, IsOptional, IsString, Matches, MaxLength, MinLength } from 'class-validator';
export class CreateContextRequestDto {
@ApiProperty({
description:
'Context type (e.g., tenant, app, workspace). Must be lowercase alphanumeric with optional separators.',
example: 'tenant',
required: true,
type: String,
pattern: CONTEXT_IDENTIFIER_REGEX.source,
})
@IsDefined()
@IsString()
@MinLength(1)
@MaxLength(100)
@Matches(CONTEXT_IDENTIFIER_REGEX, {
message: 'Type must be lowercase alphanumeric with optional ., _, or - separators',
})
type: ContextType;
@ApiProperty({
description: 'Unique identifier for this context. Must be lowercase alphanumeric with optional separators.',
example: 'org-acme',
required: true,
type: String,
pattern: CONTEXT_IDENTIFIER_REGEX.source,
})
@IsDefined()
@IsString()
@MinLength(1)
@MaxLength(100)
@Matches(CONTEXT_IDENTIFIER_REGEX, {
message: 'ID must be lowercase alphanumeric with optional ., _, or - separators',
})
id: ContextId;
@ApiPropertyOptional({
description: 'Optional custom data to associate with this context.',
example: { tenantName: 'Acme Corp', region: 'us-east-1', settings: { theme: 'dark' } },
type: Object,
additionalProperties: true,
})
@IsOptional()
@IsValidContextData()
data?: ContextData;
}