@fluojs/validation 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ko.md +26 -0
- package/README.md +26 -0
- package/dist/decorators.d.ts +67 -67
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +67 -130
- package/dist/internal/decorator-factories.d.ts +12 -0
- package/dist/internal/decorator-factories.d.ts.map +1 -0
- package/dist/internal/decorator-factories.js +32 -0
- package/dist/internal/decorator-metadata.d.ts +7 -0
- package/dist/internal/decorator-metadata.d.ts.map +1 -0
- package/dist/internal/decorator-metadata.js +38 -0
- package/dist/internal/dto-metadata-cache.d.ts +17 -0
- package/dist/internal/dto-metadata-cache.d.ts.map +1 -0
- package/dist/internal/dto-metadata-cache.js +48 -0
- package/dist/internal/object-utils.d.ts +4 -0
- package/dist/internal/object-utils.d.ts.map +1 -0
- package/dist/internal/object-utils.js +25 -0
- package/dist/internal/rule-handlers.d.ts +19 -0
- package/dist/internal/rule-handlers.d.ts.map +1 -0
- package/dist/internal/rule-handlers.js +209 -0
- package/dist/internal/validator-js-adapter.d.ts +5 -0
- package/dist/internal/validator-js-adapter.d.ts.map +1 -0
- package/dist/internal/validator-js-adapter.js +88 -0
- package/dist/mapped-types.d.ts +1 -1
- package/dist/mapped-types.d.ts.map +1 -1
- package/dist/mapped-types.js +1 -1
- package/dist/standard-schema.d.ts +1 -1
- package/dist/standard-schema.d.ts.map +1 -1
- package/dist/types.d.ts +5 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +9 -373
- package/package.json +2 -2
package/README.ko.md
CHANGED
|
@@ -74,12 +74,37 @@ class rule이 실행되기 전에 deterministic `DtoValidationError`로 거부
|
|
|
74
74
|
DTO 바인딩 메타데이터를 적용한 뒤 `@ValidateNested(...)` 필드를 재귀적으로
|
|
75
75
|
실체화합니다. 어떤 요청 소스를 선택하고 스칼라 값을 변환할지는 transport 또는
|
|
76
76
|
binder가 검증 전에 담당한다는 request-pipeline 계약을 유지합니다.
|
|
77
|
+
Plain 입력 객체를 materialize할 때 안전한 추가 own enumerable 속성은 유지됩니다. `__proto__`, `constructor`,
|
|
78
|
+
`prototype` 같은 위험한 key와 inherited 또는 non-enumerable 속성만 제외합니다.
|
|
79
|
+
이는 `ValidationPipe` 스타일의 whitelist 또는 `forbidNonWhitelisted` 경계가
|
|
80
|
+
아닙니다. 애플리케이션에 해당 정책이 필요하면 materialization 전에 추가 입력을
|
|
81
|
+
명시적으로 shaping하거나 거부해야 합니다.
|
|
77
82
|
선언된 중첩 DTO의 인스턴스인 기존 중첩 값은 그대로 보존하고, plain 중첩 값만
|
|
78
83
|
해당 필드 또는 collection entry 단위로 실체화합니다.
|
|
79
84
|
`materialize()`에 넘기는 루트 값은 plain 객체이거나 대상 DTO 인스턴스여야 합니다.
|
|
80
85
|
문자열, 배열, `null` 같은 잘못된 루트 값은 대상 DTO 생성자나 필드 initializer가
|
|
81
86
|
실행되기 전에 거부됩니다.
|
|
82
87
|
|
|
88
|
+
### 누락 값과 validation group
|
|
89
|
+
|
|
90
|
+
일반 field validator는 `null`과 `undefined`를 모두 건너뜁니다. 두 값 중 하나라도
|
|
91
|
+
누락된 필수 field로 실패해야 한다면 `@IsDefined()`를 추가하세요. Optional 계약을
|
|
92
|
+
명시하고 해당 field의 다른 validator를 short-circuit하려면 `@IsOptional()`을
|
|
93
|
+
사용할 수 있습니다.
|
|
94
|
+
|
|
95
|
+
Validation group은 지원되는 실행 surface가 아닙니다. Decorator option에는
|
|
96
|
+
class-validator 스타일의 `groups` 또는 `always`가 없고, `validate()`와
|
|
97
|
+
`materialize()`도 group 선택을 받지 않습니다. Group 기반 실행을 가정하지 말고
|
|
98
|
+
별도 DTO, mapped DTO helper, `@ValidateIf(...)`, 명시적 class-level validation으로
|
|
99
|
+
workflow 차이를 모델링하세요.
|
|
100
|
+
|
|
101
|
+
### DTO 상속
|
|
102
|
+
|
|
103
|
+
Derived DTO는 base DTO의 field-level 및 class-level validation rule을 상속합니다.
|
|
104
|
+
Derived DTO에 validation decorator를 추가하면 derived DTO가 소유하는 metadata가
|
|
105
|
+
생성되며 base DTO의 검증 동작은 바뀌지 않습니다. Mapped DTO helper가 반환한 class를
|
|
106
|
+
확장할 때도 같은 격리가 유지됩니다.
|
|
107
|
+
|
|
83
108
|
### 검증 이슈 형태
|
|
84
109
|
|
|
85
110
|
`DtoValidationError.issues`는 request-pipeline 오류 상세에 사용하는 안정적인 DTO입니다.
|
|
@@ -146,6 +171,7 @@ IPv6 모두 허용" 계약을 명시하고 싶을 때 사용할 수 있습니다
|
|
|
146
171
|
### 중첩 검증
|
|
147
172
|
|
|
148
173
|
`@ValidateNested(...)`는 객체 필드, 배열, `Set`, `Map`을 지원합니다. 중첩 DTO path는 validation issue에서 dot/index 표기법을 사용하며, cycle은 안전하게 감지되고 shared reference는 허용됩니다.
|
|
174
|
+
Array, `Set`, `Map` member는 자동으로 검증되고 실체화되므로 nested collection 순회를 활성화하기 위해 `each: true`를 지정할 필요가 없습니다. 기존 DTO를 위해 이 option은 계속 허용됩니다.
|
|
149
175
|
중첩 타입을 지연 해석해야 할 때는 DTO 클래스 자체나 `() => ChildDto`, `function resolveChildDto() { return ChildDto; }` 같은 lazy constructor factory를 전달할 수 있습니다.
|
|
150
176
|
|
|
151
177
|
### 암묵적 scalar coercion 없음
|
package/README.md
CHANGED
|
@@ -77,6 +77,11 @@ coercion.
|
|
|
77
77
|
applies DTO binding metadata, and recursively hydrates `@ValidateNested(...)`
|
|
78
78
|
fields. It preserves the request-pipeline contract that transports or binders own
|
|
79
79
|
source selection and scalar conversion before validation runs.
|
|
80
|
+
When materializing a plain input object, safe extra own enumerable properties are retained; only dangerous keys such as
|
|
81
|
+
`__proto__`, `constructor`, and `prototype`, plus inherited or non-enumerable
|
|
82
|
+
properties, are excluded. This is not a `ValidationPipe`-style whitelist or
|
|
83
|
+
`forbidNonWhitelisted` boundary. Shape or reject extra input explicitly before
|
|
84
|
+
materialization when an application requires that policy.
|
|
80
85
|
Existing nested values that are already instances of the declared nested DTO are
|
|
81
86
|
preserved; plain nested values are hydrated only for the affected nested field or
|
|
82
87
|
collection entry.
|
|
@@ -84,6 +89,26 @@ The root value passed to `materialize()` must already be a plain object or an
|
|
|
84
89
|
instance of the target DTO; malformed roots such as strings, arrays, and `null`
|
|
85
90
|
are rejected before the target DTO constructor or field initializers run.
|
|
86
91
|
|
|
92
|
+
### Missing values and validation groups
|
|
93
|
+
|
|
94
|
+
Ordinary field validators skip both `null` and `undefined`. Add `@IsDefined()`
|
|
95
|
+
when either value must fail as a missing required field. `@IsOptional()` remains
|
|
96
|
+
useful when the optional contract should be explicit and should short-circuit the
|
|
97
|
+
other validators on that field.
|
|
98
|
+
|
|
99
|
+
Validation groups are not a supported execution surface. Decorator options do
|
|
100
|
+
not include class-validator-style `groups` or `always`, and `validate()` /
|
|
101
|
+
`materialize()` do not accept a group selection. Model different workflows with
|
|
102
|
+
separate DTOs, mapped DTO helpers, `@ValidateIf(...)`, or explicit class-level
|
|
103
|
+
validation instead of assuming group-based execution.
|
|
104
|
+
|
|
105
|
+
### DTO inheritance
|
|
106
|
+
|
|
107
|
+
Derived DTOs inherit field-level and class-level validation rules from their base
|
|
108
|
+
DTO. Adding validation decorators to the derived DTO creates derived-owned
|
|
109
|
+
metadata and does not change how the base DTO validates. The same isolation holds
|
|
110
|
+
when extending a class returned by a mapped DTO helper.
|
|
111
|
+
|
|
87
112
|
### Validation issue shape
|
|
88
113
|
|
|
89
114
|
`DtoValidationError.issues` is a stable DTO for request-pipeline error details:
|
|
@@ -150,6 +175,7 @@ contract explicitly while still using the same runtime behavior as `@IsIP()`.
|
|
|
150
175
|
### Nested validation
|
|
151
176
|
|
|
152
177
|
`@ValidateNested(...)` supports object fields, arrays, `Set`, and `Map`. Nested DTO paths use dot/index notation in validation issues, cycles are detected safely, and shared references are allowed.
|
|
178
|
+
Array, `Set`, and `Map` members are validated and materialized automatically; `each: true` is not required to enable nested collection traversal. The option remains accepted for existing DTOs.
|
|
153
179
|
Pass either a DTO class or a lazy constructor factory such as `() => ChildDto` or `function resolveChildDto() { return ChildDto; }` when nested types need deferred resolution.
|
|
154
180
|
|
|
155
181
|
### No implicit scalar coercion
|
package/dist/decorators.d.ts
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import type { Constructor } from '@fluojs/core';
|
|
2
|
-
import type { CustomClassValidator, CustomFieldValidator, CustomValidationDecoratorOptions, ValidationDecoratorOptions } from '@fluojs/core/
|
|
2
|
+
import type { CustomClassValidator, CustomFieldValidator, CustomValidationDecoratorOptions, ValidationDecoratorOptions } from '@fluojs/core/request-pipeline';
|
|
3
|
+
import { type ClassDecoratorFn, type FieldDecoratorFn } from './internal/decorator-metadata.js';
|
|
3
4
|
import { type StandardSchemaV1Like } from './standard-schema.js';
|
|
4
|
-
type ClassDecoratorFn = (value: Function, context: ClassDecoratorContext) => void;
|
|
5
|
-
type FieldDecoratorFn = <This, Value>(value: undefined, context: ClassFieldDecoratorContext<This, Value>) => void;
|
|
6
5
|
type ValidateClassInput = CustomClassValidator | StandardSchemaV1Like;
|
|
7
6
|
/**
|
|
8
7
|
* Validates that the decorated field is a string value.
|
|
9
8
|
*
|
|
10
|
-
* @param options Optional validation behavior (`message`, `
|
|
9
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
11
10
|
* @returns A field decorator that registers a string validation rule.
|
|
12
11
|
*/
|
|
13
12
|
export declare function IsString(options?: ValidationDecoratorOptions): FieldDecoratorFn;
|
|
14
13
|
/**
|
|
15
14
|
* Validates that the decorated field is a number value.
|
|
16
15
|
*
|
|
17
|
-
* @param options Optional validation behavior (`message`, `
|
|
16
|
+
* @param options Optional validation behavior (`message`, `code`, `each`, `allowNaN`).
|
|
18
17
|
* @returns A field decorator that registers a number validation rule.
|
|
19
18
|
*/
|
|
20
19
|
export declare function IsNumber(options?: ValidationDecoratorOptions & {
|
|
@@ -23,7 +22,7 @@ export declare function IsNumber(options?: ValidationDecoratorOptions & {
|
|
|
23
22
|
/**
|
|
24
23
|
* Validates that the decorated field is a boolean value.
|
|
25
24
|
*
|
|
26
|
-
* @param options Optional validation behavior (`message`, `
|
|
25
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
27
26
|
* @returns A field decorator that registers a boolean validation rule.
|
|
28
27
|
*/
|
|
29
28
|
export declare function IsBoolean(options?: ValidationDecoratorOptions): FieldDecoratorFn;
|
|
@@ -31,21 +30,21 @@ export declare function IsBoolean(options?: ValidationDecoratorOptions): FieldDe
|
|
|
31
30
|
* Applies subsequent validators only when the condition returns `true`.
|
|
32
31
|
*
|
|
33
32
|
* @param validateIf Predicate that decides whether subsequent validators should run.
|
|
34
|
-
* @param options Optional validation behavior (`message`, `
|
|
33
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
35
34
|
* @returns A field decorator that adds conditional validation execution.
|
|
36
35
|
*/
|
|
37
36
|
export declare const ValidateIf: (validateIf: (dto: unknown, value: unknown) => boolean | Promise<boolean>, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
38
37
|
/**
|
|
39
38
|
* Validates that the decorated field is neither `null` nor `undefined`.
|
|
40
39
|
*
|
|
41
|
-
* @param options Optional validation behavior (`message`, `
|
|
40
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
42
41
|
* @returns A field decorator that registers a required-value rule.
|
|
43
42
|
*/
|
|
44
43
|
export declare const IsDefined: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
45
44
|
/**
|
|
46
45
|
* Skips subsequent validators when the decorated field is `null` or `undefined`.
|
|
47
46
|
*
|
|
48
|
-
* @param options Optional validation behavior (`message`, `
|
|
47
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
49
48
|
* @returns A field decorator that registers optional-value semantics.
|
|
50
49
|
*/
|
|
51
50
|
export declare const IsOptional: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
@@ -53,7 +52,7 @@ export declare const IsOptional: (options?: ValidationDecoratorOptions) => Field
|
|
|
53
52
|
* Validates that the decorated field strictly equals the expected value.
|
|
54
53
|
*
|
|
55
54
|
* @param value Expected value to compare against the field value.
|
|
56
|
-
* @param options Optional validation behavior (`message`, `
|
|
55
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
57
56
|
* @returns A field decorator that registers an equality rule.
|
|
58
57
|
*/
|
|
59
58
|
export declare const Equals: (value: unknown, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
@@ -61,21 +60,21 @@ export declare const Equals: (value: unknown, options?: ValidationDecoratorOptio
|
|
|
61
60
|
* Validates that the decorated field does not strictly equal the forbidden value.
|
|
62
61
|
*
|
|
63
62
|
* @param value Forbidden value to compare against the field value.
|
|
64
|
-
* @param options Optional validation behavior (`message`, `
|
|
63
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
65
64
|
* @returns A field decorator that registers an inequality rule.
|
|
66
65
|
*/
|
|
67
66
|
export declare const NotEquals: (value: unknown, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
68
67
|
/**
|
|
69
68
|
* Validates that the decorated field is empty.
|
|
70
69
|
*
|
|
71
|
-
* @param options Optional validation behavior (`message`, `
|
|
70
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
72
71
|
* @returns A field decorator that registers an empty-value rule.
|
|
73
72
|
*/
|
|
74
73
|
export declare const IsEmpty: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
75
74
|
/**
|
|
76
75
|
* Validates that the decorated field is not empty.
|
|
77
76
|
*
|
|
78
|
-
* @param options Optional validation behavior (`message`, `
|
|
77
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
79
78
|
* @returns A field decorator that registers a non-empty-value rule.
|
|
80
79
|
*/
|
|
81
80
|
export declare const IsNotEmpty: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
@@ -83,7 +82,7 @@ export declare const IsNotEmpty: (options?: ValidationDecoratorOptions) => Field
|
|
|
83
82
|
* Validates that the decorated field is included in the accepted values.
|
|
84
83
|
*
|
|
85
84
|
* @param values Accepted values for the field.
|
|
86
|
-
* @param options Optional validation behavior (`message`, `
|
|
85
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
87
86
|
* @returns A field decorator that registers an inclusion rule.
|
|
88
87
|
*/
|
|
89
88
|
export declare const IsIn: (values: readonly unknown[], options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
@@ -91,49 +90,49 @@ export declare const IsIn: (values: readonly unknown[], options?: ValidationDeco
|
|
|
91
90
|
* Validates that the decorated field is not included in the rejected values.
|
|
92
91
|
*
|
|
93
92
|
* @param values Rejected values for the field.
|
|
94
|
-
* @param options Optional validation behavior (`message`, `
|
|
93
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
95
94
|
* @returns A field decorator that registers an exclusion rule.
|
|
96
95
|
*/
|
|
97
96
|
export declare const IsNotIn: (values: readonly unknown[], options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
98
97
|
/**
|
|
99
98
|
* Validates that the decorated field is a `Date` value.
|
|
100
99
|
*
|
|
101
|
-
* @param options Optional validation behavior (`message`, `
|
|
100
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
102
101
|
* @returns A field decorator that registers a date validation rule.
|
|
103
102
|
*/
|
|
104
103
|
export declare const IsDate: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
105
104
|
/**
|
|
106
105
|
* Validates that the decorated field is an array.
|
|
107
106
|
*
|
|
108
|
-
* @param options Optional validation behavior (`message`, `
|
|
107
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
109
108
|
* @returns A field decorator that registers an array validation rule.
|
|
110
109
|
*/
|
|
111
110
|
export declare const IsArray: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
112
111
|
/**
|
|
113
112
|
* Validates that the decorated field is an object value.
|
|
114
113
|
*
|
|
115
|
-
* @param options Optional validation behavior (`message`, `
|
|
114
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
116
115
|
* @returns A field decorator that registers an object validation rule.
|
|
117
116
|
*/
|
|
118
117
|
export declare const IsObject: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
119
118
|
/**
|
|
120
119
|
* Validates that the decorated field is an integer.
|
|
121
120
|
*
|
|
122
|
-
* @param options Optional validation behavior (`message`, `
|
|
121
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
123
122
|
* @returns A field decorator that registers an integer validation rule.
|
|
124
123
|
*/
|
|
125
124
|
export declare const IsInt: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
126
125
|
/**
|
|
127
126
|
* Validates that the decorated field is a positive number.
|
|
128
127
|
*
|
|
129
|
-
* @param options Optional validation behavior (`message`, `
|
|
128
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
130
129
|
* @returns A field decorator that registers a positive-number rule.
|
|
131
130
|
*/
|
|
132
131
|
export declare const IsPositive: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
133
132
|
/**
|
|
134
133
|
* Validates that the decorated field is a negative number.
|
|
135
134
|
*
|
|
136
|
-
* @param options Optional validation behavior (`message`, `
|
|
135
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
137
136
|
* @returns A field decorator that registers a negative-number rule.
|
|
138
137
|
*/
|
|
139
138
|
export declare const IsNegative: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
@@ -141,7 +140,7 @@ export declare const IsNegative: (options?: ValidationDecoratorOptions) => Field
|
|
|
141
140
|
* Validates that the field value is included in the given enum-like set.
|
|
142
141
|
*
|
|
143
142
|
* @param values Enum object or literal value list that defines the accepted set.
|
|
144
|
-
* @param options Optional validation behavior (`message`, `
|
|
143
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
145
144
|
* @returns A field decorator that registers an enum-membership rule.
|
|
146
145
|
*/
|
|
147
146
|
export declare function IsEnum(values: Record<string, unknown> | readonly unknown[], options?: ValidationDecoratorOptions): FieldDecoratorFn;
|
|
@@ -149,7 +148,7 @@ export declare function IsEnum(values: Record<string, unknown> | readonly unknow
|
|
|
149
148
|
* Validates that the decorated field is divisible by the given divisor.
|
|
150
149
|
*
|
|
151
150
|
* @param value Divisor used for the numeric divisibility check.
|
|
152
|
-
* @param options Optional validation behavior (`message`, `
|
|
151
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
153
152
|
* @returns A field decorator that registers a divisibility rule.
|
|
154
153
|
*/
|
|
155
154
|
export declare const IsDivisibleBy: (value: number, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
@@ -157,7 +156,7 @@ export declare const IsDivisibleBy: (value: number, options?: ValidationDecorato
|
|
|
157
156
|
* Validates that the decorated field is greater than or equal to the minimum.
|
|
158
157
|
*
|
|
159
158
|
* @param value Inclusive minimum allowed numeric value.
|
|
160
|
-
* @param options Optional validation behavior (`message`, `
|
|
159
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
161
160
|
* @returns A field decorator that registers a minimum-value rule.
|
|
162
161
|
*/
|
|
163
162
|
export declare const Min: (value: number, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
@@ -165,7 +164,7 @@ export declare const Min: (value: number, options?: ValidationDecoratorOptions)
|
|
|
165
164
|
* Validates that the decorated field is less than or equal to the maximum.
|
|
166
165
|
*
|
|
167
166
|
* @param value Inclusive maximum allowed numeric value.
|
|
168
|
-
* @param options Optional validation behavior (`message`, `
|
|
167
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
169
168
|
* @returns A field decorator that registers a maximum-value rule.
|
|
170
169
|
*/
|
|
171
170
|
export declare const Max: (value: number, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
@@ -173,7 +172,7 @@ export declare const Max: (value: number, options?: ValidationDecoratorOptions)
|
|
|
173
172
|
* Validates that the decorated field is on or after the minimum date.
|
|
174
173
|
*
|
|
175
174
|
* @param value Inclusive minimum allowed date.
|
|
176
|
-
* @param options Optional validation behavior (`message`, `
|
|
175
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
177
176
|
* @returns A field decorator that registers a minimum-date rule.
|
|
178
177
|
*/
|
|
179
178
|
export declare const MinDate: (value: Date, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
@@ -181,7 +180,7 @@ export declare const MinDate: (value: Date, options?: ValidationDecoratorOptions
|
|
|
181
180
|
* Validates that the decorated field is on or before the maximum date.
|
|
182
181
|
*
|
|
183
182
|
* @param value Inclusive maximum allowed date.
|
|
184
|
-
* @param options Optional validation behavior (`message`, `
|
|
183
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
185
184
|
* @returns A field decorator that registers a maximum-date rule.
|
|
186
185
|
*/
|
|
187
186
|
export declare const MaxDate: (value: Date, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
@@ -189,7 +188,7 @@ export declare const MaxDate: (value: Date, options?: ValidationDecoratorOptions
|
|
|
189
188
|
* Validates that the decorated field contains the required substring.
|
|
190
189
|
*
|
|
191
190
|
* @param value Required substring.
|
|
192
|
-
* @param options Optional validation behavior (`message`, `
|
|
191
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
193
192
|
* @returns A field decorator that registers a substring-presence rule.
|
|
194
193
|
*/
|
|
195
194
|
export declare const Contains: (value: string, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
@@ -197,7 +196,7 @@ export declare const Contains: (value: string, options?: ValidationDecoratorOpti
|
|
|
197
196
|
* Validates that the decorated field does not contain the forbidden substring.
|
|
198
197
|
*
|
|
199
198
|
* @param value Forbidden substring.
|
|
200
|
-
* @param options Optional validation behavior (`message`, `
|
|
199
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
201
200
|
* @returns A field decorator that registers a substring-exclusion rule.
|
|
202
201
|
*/
|
|
203
202
|
export declare const NotContains: (value: string, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
@@ -206,15 +205,16 @@ export declare const NotContains: (value: string, options?: ValidationDecoratorO
|
|
|
206
205
|
*
|
|
207
206
|
* @param min Minimum inclusive length.
|
|
208
207
|
* @param max Optional maximum inclusive length.
|
|
209
|
-
* @param options Optional validation behavior (`message`, `
|
|
208
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
210
209
|
* @returns A field decorator that registers a bounded-length rule.
|
|
211
210
|
*/
|
|
212
211
|
export declare function Length(min: number, max?: number, options?: ValidationDecoratorOptions): FieldDecoratorFn;
|
|
213
212
|
/**
|
|
214
213
|
* Validates a nested DTO instance using the provided constructor.
|
|
214
|
+
* Arrays, Sets, and Maps are traversed automatically without requiring `each`.
|
|
215
215
|
*
|
|
216
216
|
* @param dto DTO constructor (or lazy constructor factory) used for nested validation/materialization.
|
|
217
|
-
* @param options Optional validation behavior (`message`, `
|
|
217
|
+
* @param options Optional validation behavior (`message`, `code`, `each`); collection traversal is automatic.
|
|
218
218
|
* @returns A field decorator that registers recursive nested DTO validation.
|
|
219
219
|
*/
|
|
220
220
|
export declare function ValidateNested(dto: Constructor | (() => Constructor), options?: ValidationDecoratorOptions): FieldDecoratorFn;
|
|
@@ -222,7 +222,7 @@ export declare function ValidateNested(dto: Constructor | (() => Constructor), o
|
|
|
222
222
|
* Validates that the decorated field has at least the given length.
|
|
223
223
|
*
|
|
224
224
|
* @param value Inclusive minimum string length.
|
|
225
|
-
* @param options Optional validation behavior (`message`, `
|
|
225
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
226
226
|
* @returns A field decorator that registers a minimum-length rule.
|
|
227
227
|
*/
|
|
228
228
|
export declare const MinLength: (value: number, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
@@ -230,7 +230,7 @@ export declare const MinLength: (value: number, options?: ValidationDecoratorOpt
|
|
|
230
230
|
* Validates that the decorated field has at most the given length.
|
|
231
231
|
*
|
|
232
232
|
* @param value Inclusive maximum string length.
|
|
233
|
-
* @param options Optional validation behavior (`message`, `
|
|
233
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
234
234
|
* @returns A field decorator that registers a maximum-length rule.
|
|
235
235
|
*/
|
|
236
236
|
export declare const MaxLength: (value: number, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
@@ -246,196 +246,196 @@ export declare function Matches(pattern: RegExp | string, modifiersOrOptions?: s
|
|
|
246
246
|
/**
|
|
247
247
|
* Validates that the decorated field contains only alphabetic characters.
|
|
248
248
|
*
|
|
249
|
-
* @param options Optional validation behavior (`message`, `
|
|
249
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
250
250
|
* @returns A field decorator that registers an alphabetic string rule.
|
|
251
251
|
*/
|
|
252
252
|
export declare const IsAlpha: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
253
253
|
/**
|
|
254
254
|
* Validates that the decorated field contains only alphanumeric characters.
|
|
255
255
|
*
|
|
256
|
-
* @param options Optional validation behavior (`message`, `
|
|
256
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
257
257
|
* @returns A field decorator that registers an alphanumeric string rule.
|
|
258
258
|
*/
|
|
259
259
|
export declare const IsAlphanumeric: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
260
260
|
/**
|
|
261
261
|
* Validates that the decorated field contains only ASCII characters.
|
|
262
262
|
*
|
|
263
|
-
* @param options Optional validation behavior (`message`, `
|
|
263
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
264
264
|
* @returns A field decorator that registers an ASCII string rule.
|
|
265
265
|
*/
|
|
266
266
|
export declare const IsAscii: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
267
267
|
/**
|
|
268
268
|
* Validates that the decorated field is a Base64 string.
|
|
269
269
|
*
|
|
270
|
-
* @param options Optional validation behavior (`message`, `
|
|
270
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
271
271
|
* @returns A field decorator that registers a Base64 string rule.
|
|
272
272
|
*/
|
|
273
273
|
export declare const IsBase64: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
274
274
|
/**
|
|
275
275
|
* Validates that the decorated field is a boolean-like string.
|
|
276
276
|
*
|
|
277
|
-
* @param options Optional validation behavior (`message`, `
|
|
277
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
278
278
|
* @returns A field decorator that registers a boolean-string rule.
|
|
279
279
|
*/
|
|
280
280
|
export declare const IsBooleanString: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
281
281
|
/**
|
|
282
282
|
* Validates that the decorated field is a data URI string.
|
|
283
283
|
*
|
|
284
|
-
* @param options Optional validation behavior (`message`, `
|
|
284
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
285
285
|
* @returns A field decorator that registers a data URI rule.
|
|
286
286
|
*/
|
|
287
287
|
export declare const IsDataURI: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
288
288
|
/**
|
|
289
289
|
* Validates that the decorated field is a date string.
|
|
290
290
|
*
|
|
291
|
-
* @param options Optional validation behavior (`message`, `
|
|
291
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
292
292
|
* @returns A field decorator that registers a date-string rule.
|
|
293
293
|
*/
|
|
294
294
|
export declare const IsDateString: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
295
295
|
/**
|
|
296
296
|
* Validates that the decorated field is a decimal string.
|
|
297
297
|
*
|
|
298
|
-
* @param options Optional validation behavior (`message`, `
|
|
298
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
299
299
|
* @returns A field decorator that registers a decimal-string rule.
|
|
300
300
|
*/
|
|
301
301
|
export declare const IsDecimal: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
302
302
|
/**
|
|
303
303
|
* Validates that the decorated field is an email address.
|
|
304
304
|
*
|
|
305
|
-
* @param options Optional validation behavior (`message`, `
|
|
305
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
306
306
|
* @returns A field decorator that registers an email-address rule.
|
|
307
307
|
*/
|
|
308
308
|
export declare const IsEmail: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
309
309
|
/**
|
|
310
310
|
* Validates that the decorated field is a fully qualified domain name.
|
|
311
311
|
*
|
|
312
|
-
* @param options Optional validation behavior (`message`, `
|
|
312
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
313
313
|
* @returns A field decorator that registers an FQDN rule.
|
|
314
314
|
*/
|
|
315
315
|
export declare const IsFQDN: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
316
316
|
/**
|
|
317
317
|
* Validates that the decorated field is a hexadecimal color string.
|
|
318
318
|
*
|
|
319
|
-
* @param options Optional validation behavior (`message`, `
|
|
319
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
320
320
|
* @returns A field decorator that registers a hex-color rule.
|
|
321
321
|
*/
|
|
322
322
|
export declare const IsHexColor: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
323
323
|
/**
|
|
324
324
|
* Validates that the decorated field is a hexadecimal string.
|
|
325
325
|
*
|
|
326
|
-
* @param options Optional validation behavior (`message`, `
|
|
326
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
327
327
|
* @returns A field decorator that registers a hexadecimal string rule.
|
|
328
328
|
*/
|
|
329
329
|
export declare const IsHexadecimal: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
330
330
|
/**
|
|
331
331
|
* Validates that the decorated field is a JSON string.
|
|
332
332
|
*
|
|
333
|
-
* @param options Optional validation behavior (`message`, `
|
|
333
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
334
334
|
* @returns A field decorator that registers a JSON-string rule.
|
|
335
335
|
*/
|
|
336
336
|
export declare const IsJSON: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
337
337
|
/**
|
|
338
338
|
* Validates that the decorated field is a JSON Web Token string.
|
|
339
339
|
*
|
|
340
|
-
* @param options Optional validation behavior (`message`, `
|
|
340
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
341
341
|
* @returns A field decorator that registers a JWT-string rule.
|
|
342
342
|
*/
|
|
343
343
|
export declare const IsJWT: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
344
344
|
/**
|
|
345
345
|
* Validates that the decorated field is a locale identifier.
|
|
346
346
|
*
|
|
347
|
-
* @param options Optional validation behavior (`message`, `
|
|
347
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
348
348
|
* @returns A field decorator that registers a locale-string rule.
|
|
349
349
|
*/
|
|
350
350
|
export declare const IsLocale: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
351
351
|
/**
|
|
352
352
|
* Validates that the decorated field is lowercase.
|
|
353
353
|
*
|
|
354
|
-
* @param options Optional validation behavior (`message`, `
|
|
354
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
355
355
|
* @returns A field decorator that registers a lowercase-string rule.
|
|
356
356
|
*/
|
|
357
357
|
export declare const IsLowercase: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
358
358
|
/**
|
|
359
359
|
* Validates that the decorated field is a magnet URI string.
|
|
360
360
|
*
|
|
361
|
-
* @param options Optional validation behavior (`message`, `
|
|
361
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
362
362
|
* @returns A field decorator that registers a magnet URI rule.
|
|
363
363
|
*/
|
|
364
364
|
export declare const IsMagnetURI: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
365
365
|
/**
|
|
366
366
|
* Validates that the decorated field is a MIME type string.
|
|
367
367
|
*
|
|
368
|
-
* @param options Optional validation behavior (`message`, `
|
|
368
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
369
369
|
* @returns A field decorator that registers a MIME type rule.
|
|
370
370
|
*/
|
|
371
371
|
export declare const IsMimeType: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
372
372
|
/**
|
|
373
373
|
* Validates that the decorated field is a MongoDB object ID string.
|
|
374
374
|
*
|
|
375
|
-
* @param options Optional validation behavior (`message`, `
|
|
375
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
376
376
|
* @returns A field decorator that registers a MongoDB object ID rule.
|
|
377
377
|
*/
|
|
378
378
|
export declare const IsMongoId: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
379
379
|
/**
|
|
380
380
|
* Validates that the decorated field is a numeric string.
|
|
381
381
|
*
|
|
382
|
-
* @param options Optional validation behavior (`message`, `
|
|
382
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
383
383
|
* @returns A field decorator that registers a numeric-string rule.
|
|
384
384
|
*/
|
|
385
385
|
export declare const IsNumberString: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
386
386
|
/**
|
|
387
387
|
* Validates that the decorated field is a network port string.
|
|
388
388
|
*
|
|
389
|
-
* @param options Optional validation behavior (`message`, `
|
|
389
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
390
390
|
* @returns A field decorator that registers a port-string rule.
|
|
391
391
|
*/
|
|
392
392
|
export declare const IsPort: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
393
393
|
/**
|
|
394
394
|
* Validates that the decorated field is an RFC 3339 date-time string.
|
|
395
395
|
*
|
|
396
|
-
* @param options Optional validation behavior (`message`, `
|
|
396
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
397
397
|
* @returns A field decorator that registers an RFC 3339 string rule.
|
|
398
398
|
*/
|
|
399
399
|
export declare const IsRFC3339: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
400
400
|
/**
|
|
401
401
|
* Validates that the decorated field is a semantic version string.
|
|
402
402
|
*
|
|
403
|
-
* @param options Optional validation behavior (`message`, `
|
|
403
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
404
404
|
* @returns A field decorator that registers a semantic-version rule.
|
|
405
405
|
*/
|
|
406
406
|
export declare const IsSemVer: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
407
407
|
/**
|
|
408
408
|
* Validates that the decorated field is uppercase.
|
|
409
409
|
*
|
|
410
|
-
* @param options Optional validation behavior (`message`, `
|
|
410
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
411
411
|
* @returns A field decorator that registers an uppercase-string rule.
|
|
412
412
|
*/
|
|
413
413
|
export declare const IsUppercase: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
414
414
|
/**
|
|
415
415
|
* Validates that the decorated field is an ISO 8601 date-time string.
|
|
416
416
|
*
|
|
417
|
-
* @param options Optional validation behavior (`message`, `
|
|
417
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
418
418
|
* @returns A field decorator that registers an ISO 8601 string rule.
|
|
419
419
|
*/
|
|
420
420
|
export declare const IsISO8601: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
421
421
|
/**
|
|
422
422
|
* Validates that the decorated field is a latitude value.
|
|
423
423
|
*
|
|
424
|
-
* @param options Optional validation behavior (`message`, `
|
|
424
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
425
425
|
* @returns A field decorator that registers a latitude rule.
|
|
426
426
|
*/
|
|
427
427
|
export declare const IsLatitude: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
428
428
|
/**
|
|
429
429
|
* Validates that the decorated field is a longitude value.
|
|
430
430
|
*
|
|
431
|
-
* @param options Optional validation behavior (`message`, `
|
|
431
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
432
432
|
* @returns A field decorator that registers a longitude rule.
|
|
433
433
|
*/
|
|
434
434
|
export declare const IsLongitude: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
435
435
|
/**
|
|
436
436
|
* Validates that the decorated field is a latitude/longitude coordinate string.
|
|
437
437
|
*
|
|
438
|
-
* @param options Optional validation behavior (`message`, `
|
|
438
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
439
439
|
* @returns A field decorator that registers a latitude/longitude rule.
|
|
440
440
|
*/
|
|
441
441
|
export declare const IsLatLong: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
@@ -447,7 +447,7 @@ export declare const IsLatLong: (options?: ValidationDecoratorOptions) => FieldD
|
|
|
447
447
|
* version only.
|
|
448
448
|
*
|
|
449
449
|
* @param version Optional IP version filter (`'4'`, `'6'`, or `'4_or_6'`).
|
|
450
|
-
* @param options Optional validation behavior (`message`, `
|
|
450
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
451
451
|
* @returns A field decorator that registers an IP-address rule.
|
|
452
452
|
*/
|
|
453
453
|
export declare function IsIP(version?: '4' | '6' | '4_or_6', options?: ValidationDecoratorOptions): FieldDecoratorFn;
|
|
@@ -516,7 +516,7 @@ export declare function IsCurrency(options?: ValidationDecoratorOptions): FieldD
|
|
|
516
516
|
* Validates that the decorated array contains all required values.
|
|
517
517
|
*
|
|
518
518
|
* @param values Required values that must be present in the array.
|
|
519
|
-
* @param options Optional validation behavior (`message`, `
|
|
519
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
520
520
|
* @returns A field decorator that registers an array-contains rule.
|
|
521
521
|
*/
|
|
522
522
|
export declare const ArrayContains: (values: readonly unknown[], options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
@@ -524,14 +524,14 @@ export declare const ArrayContains: (values: readonly unknown[], options?: Valid
|
|
|
524
524
|
* Validates that the decorated array excludes all forbidden values.
|
|
525
525
|
*
|
|
526
526
|
* @param values Forbidden values that must not be present in the array.
|
|
527
|
-
* @param options Optional validation behavior (`message`, `
|
|
527
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
528
528
|
* @returns A field decorator that registers an array-exclusion rule.
|
|
529
529
|
*/
|
|
530
530
|
export declare const ArrayNotContains: (values: readonly unknown[], options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
531
531
|
/**
|
|
532
532
|
* Validates that the decorated array is not empty.
|
|
533
533
|
*
|
|
534
|
-
* @param options Optional validation behavior (`message`, `
|
|
534
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
535
535
|
* @returns A field decorator that registers a non-empty-array rule.
|
|
536
536
|
*/
|
|
537
537
|
export declare const ArrayNotEmpty: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
@@ -539,7 +539,7 @@ export declare const ArrayNotEmpty: (options?: ValidationDecoratorOptions) => Fi
|
|
|
539
539
|
* Validates that the decorated array has at least the given size.
|
|
540
540
|
*
|
|
541
541
|
* @param value Inclusive minimum array length.
|
|
542
|
-
* @param options Optional validation behavior (`message`, `
|
|
542
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
543
543
|
* @returns A field decorator that registers a minimum-array-size rule.
|
|
544
544
|
*/
|
|
545
545
|
export declare const ArrayMinSize: (value: number, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
@@ -547,7 +547,7 @@ export declare const ArrayMinSize: (value: number, options?: ValidationDecorator
|
|
|
547
547
|
* Validates that the decorated array has at most the given size.
|
|
548
548
|
*
|
|
549
549
|
* @param value Inclusive maximum array length.
|
|
550
|
-
* @param options Optional validation behavior (`message`, `
|
|
550
|
+
* @param options Optional validation behavior (`message`, `code`, `each`).
|
|
551
551
|
* @returns A field decorator that registers a maximum-array-size rule.
|
|
552
552
|
*/
|
|
553
553
|
export declare const ArrayMaxSize: (value: number, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|