@fluojs/validation 1.0.0-beta.1 → 1.0.0-beta.2
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 +32 -3
- package/README.md +34 -3
- package/dist/decorators.d.ts +284 -2
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +296 -2
- package/dist/errors.d.ts +3 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/standard-schema.d.ts +18 -0
- package/dist/standard-schema.d.ts.map +1 -1
- package/dist/standard-schema.js +21 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/validation.d.ts +4 -1
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +15 -2
- package/package.json +2 -2
package/README.ko.md
CHANGED
|
@@ -60,7 +60,32 @@ console.log(user.name); // "Ko"
|
|
|
60
60
|
### 실체화 vs 검증 (Materialization vs Validation)
|
|
61
61
|
|
|
62
62
|
- **`materialize<T>(value, target)`**: **입력 처리**에 가장 적합합니다. plain 객체를 받아 대상 클래스의 인스턴스를 생성하고, 값을 복사하며, 중첩된 DTO를 재귀적으로 처리한 후 모든 검증 규칙을 실행합니다.
|
|
63
|
-
- **`validate(instance, target)`**: **기존 객체 확인**에 적합합니다. 이미 생성된
|
|
63
|
+
- **`validate(instance, target)`**: **기존 루트 객체 확인**에 적합합니다. 이미 생성된 루트 값에 대해 검증 규칙을 실행하며, plain 객체인 `@ValidateNested(...)` 값은 중첩 DTO 규칙을 실행하기 위해 임시로 실체화할 수 있습니다. 이 임시 실체화는 호출자가 넘긴 속성 값을 대체하지 않습니다.
|
|
64
|
+
|
|
65
|
+
`materialize()`는 plain 입력 객체의 안전한 own enumerable 속성을 복사하고,
|
|
66
|
+
DTO 바인딩 메타데이터를 적용한 뒤 `@ValidateNested(...)` 필드를 재귀적으로
|
|
67
|
+
실체화합니다. 어떤 요청 소스를 선택하고 스칼라 값을 변환할지는 transport 또는
|
|
68
|
+
binder가 검증 전에 담당한다는 request-pipeline 계약을 유지합니다.
|
|
69
|
+
`materialize()`에 넘기는 루트 값은 plain 객체이거나 대상 DTO 인스턴스여야 합니다.
|
|
70
|
+
문자열, 배열, `null` 같은 잘못된 루트 값은 대상 DTO 생성자나 필드 initializer가
|
|
71
|
+
실행되기 전에 거부됩니다.
|
|
72
|
+
|
|
73
|
+
### 검증 이슈 형태
|
|
74
|
+
|
|
75
|
+
`DtoValidationError.issues`는 request-pipeline 오류 상세에 사용하는 안정적인 DTO입니다.
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
type ValidationIssue = {
|
|
79
|
+
code: string;
|
|
80
|
+
field?: string;
|
|
81
|
+
message: string;
|
|
82
|
+
source?: 'path' | 'query' | 'header' | 'cookie' | 'body';
|
|
83
|
+
};
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
중첩 DTO는 `address.city`, `items[0].name` 같은 dot path와 collection index를
|
|
87
|
+
사용합니다. HTTP 바인딩에서 온 규칙은 `source`를 붙이며, standalone validation이나
|
|
88
|
+
Standard Schema 이슈에서는 값이 없을 수 있습니다.
|
|
64
89
|
|
|
65
90
|
### Mapped Types (Pick, Omit, Partial)
|
|
66
91
|
|
|
@@ -121,9 +146,13 @@ class UserDto {
|
|
|
121
146
|
|
|
122
147
|
## 공개 API
|
|
123
148
|
|
|
124
|
-
- **검증 엔진**: `DefaultValidator`, `DtoValidationError`, `ValidationIssue`
|
|
125
|
-
- **핵심 데코레이터**: `IsString`, `IsNumber`, `IsBoolean`, `
|
|
149
|
+
- **검증 엔진**: `DefaultValidator`, `DtoValidationError`, `ValidationIssue`, `Validator`
|
|
150
|
+
- **핵심 데코레이터**: `IsString`, `IsNumber`, `IsBoolean`, `IsDate`, `IsArray`, `IsObject`, `IsEnum`, `IsInt`, `IsDefined`, `IsOptional`, `ValidateNested`, `ValidateIf`, `Validate`, `ValidateClass`
|
|
151
|
+
- **문자열 및 네트워크 데코레이터**: `IsEmail`, `IsUrl`, `IsUUID`, `IsIP`, `IsAlpha`, `IsAlphanumeric`, `IsAscii`, `IsBase64`, `IsDateString`, `IsJSON`, `IsJWT`, `IsNumberString`, `IsISO8601`, `Matches`, `Length`, `MinLength`, `MaxLength`, `Contains`, `NotContains`
|
|
152
|
+
- **숫자 및 날짜 데코레이터**: `Min`, `Max`, `IsPositive`, `IsNegative`, `IsDivisibleBy`, `MinDate`, `MaxDate`
|
|
153
|
+
- **배열 데코레이터**: `ArrayContains`, `ArrayNotContains`, `ArrayNotEmpty`, `ArrayMinSize`, `ArrayMaxSize`, `ArrayUnique`
|
|
126
154
|
- **Mapped DTO 헬퍼**: `PickType`, `OmitType`, `PartialType`, `IntersectionType`
|
|
155
|
+
- **Standard Schema 계약**: `ValidateClass(...)` 스키마를 타입 지정하기 위한 `StandardSchemaV1Like`
|
|
127
156
|
- **검증 흐름**: 실체화 및 검증을 위한 `materialize()`, 단순 검증을 위한 `validate()`
|
|
128
157
|
|
|
129
158
|
## 관련 패키지
|
package/README.md
CHANGED
|
@@ -62,7 +62,34 @@ try {
|
|
|
62
62
|
### `materialize()` vs `validate()`
|
|
63
63
|
|
|
64
64
|
- `materialize(value, Target)` builds a typed instance and validates it recursively
|
|
65
|
-
- `validate(instance, Target)`
|
|
65
|
+
- `validate(instance, Target)` validates an already-created root value and may
|
|
66
|
+
temporarily materialize plain nested `@ValidateNested(...)` values to run their
|
|
67
|
+
nested DTO rules without replacing the caller's properties
|
|
68
|
+
|
|
69
|
+
`materialize()` copies safe own enumerable properties from plain input objects,
|
|
70
|
+
applies DTO binding metadata, and recursively hydrates `@ValidateNested(...)`
|
|
71
|
+
fields. It preserves the request-pipeline contract that transports or binders own
|
|
72
|
+
source selection and scalar conversion before validation runs.
|
|
73
|
+
The root value passed to `materialize()` must already be a plain object or an
|
|
74
|
+
instance of the target DTO; malformed roots such as strings, arrays, and `null`
|
|
75
|
+
are rejected before the target DTO constructor or field initializers run.
|
|
76
|
+
|
|
77
|
+
### Validation issue shape
|
|
78
|
+
|
|
79
|
+
`DtoValidationError.issues` is a stable DTO for request-pipeline error details:
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
type ValidationIssue = {
|
|
83
|
+
code: string;
|
|
84
|
+
field?: string;
|
|
85
|
+
message: string;
|
|
86
|
+
source?: 'path' | 'query' | 'header' | 'cookie' | 'body';
|
|
87
|
+
};
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Nested DTOs use dot paths and collection indexes, such as `address.city` or
|
|
91
|
+
`items[0].name`. HTTP bindings attach `source` when the rule came from request
|
|
92
|
+
metadata; standalone validation and Standard Schema issues may leave it unset.
|
|
66
93
|
|
|
67
94
|
### Mapped DTO helpers
|
|
68
95
|
|
|
@@ -100,9 +127,13 @@ class RestrictedUserDto {
|
|
|
100
127
|
|
|
101
128
|
## Public API
|
|
102
129
|
|
|
103
|
-
- **Validator engine**: `DefaultValidator`, `DtoValidationError`, `ValidationIssue`
|
|
104
|
-
- **Core decorators**: `IsString`, `IsNumber`, `IsBoolean`, `
|
|
130
|
+
- **Validator engine**: `DefaultValidator`, `DtoValidationError`, `ValidationIssue`, `Validator`
|
|
131
|
+
- **Core decorators**: `IsString`, `IsNumber`, `IsBoolean`, `IsDate`, `IsArray`, `IsObject`, `IsEnum`, `IsInt`, `IsDefined`, `IsOptional`, `ValidateNested`, `ValidateIf`, `Validate`, `ValidateClass`
|
|
132
|
+
- **String and network decorators**: `IsEmail`, `IsUrl`, `IsUUID`, `IsIP`, `IsAlpha`, `IsAlphanumeric`, `IsAscii`, `IsBase64`, `IsDateString`, `IsJSON`, `IsJWT`, `IsNumberString`, `IsISO8601`, `Matches`, `Length`, `MinLength`, `MaxLength`, `Contains`, `NotContains`
|
|
133
|
+
- **Number and date decorators**: `Min`, `Max`, `IsPositive`, `IsNegative`, `IsDivisibleBy`, `MinDate`, `MaxDate`
|
|
134
|
+
- **Array decorators**: `ArrayContains`, `ArrayNotContains`, `ArrayNotEmpty`, `ArrayMinSize`, `ArrayMaxSize`, `ArrayUnique`
|
|
105
135
|
- **Mapped DTO helpers**: `PickType`, `OmitType`, `PartialType`, `IntersectionType`
|
|
136
|
+
- **Standard Schema contract**: `StandardSchemaV1Like` for typing `ValidateClass(...)` schemas
|
|
106
137
|
- **Validation flow**: `materialize()` for hydration + validation, `validate()` for validation-only checks
|
|
107
138
|
|
|
108
139
|
## Related Packages
|
package/dist/decorators.d.ts
CHANGED
|
@@ -35,19 +35,61 @@ export declare function IsBoolean(options?: ValidationDecoratorOptions): FieldDe
|
|
|
35
35
|
* @returns A field decorator that adds conditional validation execution.
|
|
36
36
|
*/
|
|
37
37
|
export declare const ValidateIf: (validateIf: (dto: unknown, value: unknown) => boolean | Promise<boolean>, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
38
|
+
/**
|
|
39
|
+
* Provides the is defined value.
|
|
40
|
+
*/
|
|
38
41
|
export declare const IsDefined: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
42
|
+
/**
|
|
43
|
+
* Provides the is optional value.
|
|
44
|
+
*/
|
|
39
45
|
export declare const IsOptional: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
46
|
+
/**
|
|
47
|
+
* Provides the equals value.
|
|
48
|
+
*/
|
|
40
49
|
export declare const Equals: (value: unknown, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
50
|
+
/**
|
|
51
|
+
* Provides the not equals value.
|
|
52
|
+
*/
|
|
41
53
|
export declare const NotEquals: (value: unknown, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
54
|
+
/**
|
|
55
|
+
* Provides the is empty value.
|
|
56
|
+
*/
|
|
42
57
|
export declare const IsEmpty: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
58
|
+
/**
|
|
59
|
+
* Provides the is not empty value.
|
|
60
|
+
*/
|
|
43
61
|
export declare const IsNotEmpty: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
62
|
+
/**
|
|
63
|
+
* Provides the is in value.
|
|
64
|
+
*/
|
|
44
65
|
export declare const IsIn: (values: readonly unknown[], options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
66
|
+
/**
|
|
67
|
+
* Provides the is not in value.
|
|
68
|
+
*/
|
|
45
69
|
export declare const IsNotIn: (values: readonly unknown[], options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
70
|
+
/**
|
|
71
|
+
* Provides the is date value.
|
|
72
|
+
*/
|
|
46
73
|
export declare const IsDate: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
74
|
+
/**
|
|
75
|
+
* Provides the is array value.
|
|
76
|
+
*/
|
|
47
77
|
export declare const IsArray: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
78
|
+
/**
|
|
79
|
+
* Provides the is object value.
|
|
80
|
+
*/
|
|
48
81
|
export declare const IsObject: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
82
|
+
/**
|
|
83
|
+
* Provides the is int value.
|
|
84
|
+
*/
|
|
49
85
|
export declare const IsInt: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
86
|
+
/**
|
|
87
|
+
* Provides the is positive value.
|
|
88
|
+
*/
|
|
50
89
|
export declare const IsPositive: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
90
|
+
/**
|
|
91
|
+
* Provides the is negative value.
|
|
92
|
+
*/
|
|
51
93
|
export declare const IsNegative: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
52
94
|
/**
|
|
53
95
|
* Validates that the field value is included in the given enum-like set.
|
|
@@ -57,12 +99,33 @@ export declare const IsNegative: (options?: ValidationDecoratorOptions) => Field
|
|
|
57
99
|
* @returns A field decorator that registers an enum-membership rule.
|
|
58
100
|
*/
|
|
59
101
|
export declare function IsEnum(values: Record<string, unknown> | readonly unknown[], options?: ValidationDecoratorOptions): FieldDecoratorFn;
|
|
102
|
+
/**
|
|
103
|
+
* Provides the is divisible by value.
|
|
104
|
+
*/
|
|
60
105
|
export declare const IsDivisibleBy: (value: number, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
106
|
+
/**
|
|
107
|
+
* Provides the min value.
|
|
108
|
+
*/
|
|
61
109
|
export declare const Min: (value: number, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
110
|
+
/**
|
|
111
|
+
* Provides the max value.
|
|
112
|
+
*/
|
|
62
113
|
export declare const Max: (value: number, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
114
|
+
/**
|
|
115
|
+
* Provides the min date value.
|
|
116
|
+
*/
|
|
63
117
|
export declare const MinDate: (value: Date, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
118
|
+
/**
|
|
119
|
+
* Provides the max date value.
|
|
120
|
+
*/
|
|
64
121
|
export declare const MaxDate: (value: Date, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
122
|
+
/**
|
|
123
|
+
* Provides the contains value.
|
|
124
|
+
*/
|
|
65
125
|
export declare const Contains: (value: string, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
126
|
+
/**
|
|
127
|
+
* Provides the not contains value.
|
|
128
|
+
*/
|
|
66
129
|
export declare const NotContains: (value: string, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
67
130
|
/**
|
|
68
131
|
* Validates string length using optional min/max boundaries.
|
|
@@ -81,7 +144,13 @@ export declare function Length(min: number, max?: number, options?: ValidationDe
|
|
|
81
144
|
* @returns A field decorator that registers recursive nested DTO validation.
|
|
82
145
|
*/
|
|
83
146
|
export declare function ValidateNested(dto: Constructor | (() => Constructor), options?: ValidationDecoratorOptions): FieldDecoratorFn;
|
|
147
|
+
/**
|
|
148
|
+
* Provides the min length value.
|
|
149
|
+
*/
|
|
84
150
|
export declare const MinLength: (value: number, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
151
|
+
/**
|
|
152
|
+
* Provides the max length value.
|
|
153
|
+
*/
|
|
85
154
|
export declare const MaxLength: (value: number, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
86
155
|
/**
|
|
87
156
|
* Validates the field using a regular expression pattern.
|
|
@@ -92,49 +161,262 @@ export declare const MaxLength: (value: number, options?: ValidationDecoratorOpt
|
|
|
92
161
|
* @returns A field decorator that registers a regex-matching rule.
|
|
93
162
|
*/
|
|
94
163
|
export declare function Matches(pattern: RegExp | string, modifiersOrOptions?: string | ValidationDecoratorOptions, options?: ValidationDecoratorOptions): FieldDecoratorFn;
|
|
164
|
+
/**
|
|
165
|
+
* Provides the is alpha value.
|
|
166
|
+
*
|
|
167
|
+
* @param options The options.
|
|
168
|
+
*/
|
|
95
169
|
export declare const IsAlpha: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
170
|
+
/**
|
|
171
|
+
* Provides the is alphanumeric value.
|
|
172
|
+
*
|
|
173
|
+
* @param options The options.
|
|
174
|
+
*/
|
|
96
175
|
export declare const IsAlphanumeric: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
176
|
+
/**
|
|
177
|
+
* Provides the is ascii value.
|
|
178
|
+
*
|
|
179
|
+
* @param options The options.
|
|
180
|
+
*/
|
|
97
181
|
export declare const IsAscii: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
182
|
+
/**
|
|
183
|
+
* Provides the is base64 value.
|
|
184
|
+
*
|
|
185
|
+
* @param options The options.
|
|
186
|
+
*/
|
|
98
187
|
export declare const IsBase64: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
188
|
+
/**
|
|
189
|
+
* Provides the is boolean string value.
|
|
190
|
+
*
|
|
191
|
+
* @param options The options.
|
|
192
|
+
*/
|
|
99
193
|
export declare const IsBooleanString: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
194
|
+
/**
|
|
195
|
+
* Provides the is data uri value.
|
|
196
|
+
*
|
|
197
|
+
* @param options The options.
|
|
198
|
+
*/
|
|
100
199
|
export declare const IsDataURI: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
200
|
+
/**
|
|
201
|
+
* Provides the is date string value.
|
|
202
|
+
*
|
|
203
|
+
* @param options The options.
|
|
204
|
+
*/
|
|
101
205
|
export declare const IsDateString: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
206
|
+
/**
|
|
207
|
+
* Provides the is decimal value.
|
|
208
|
+
*
|
|
209
|
+
* @param options The options.
|
|
210
|
+
*/
|
|
102
211
|
export declare const IsDecimal: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
212
|
+
/**
|
|
213
|
+
* Provides the is email value.
|
|
214
|
+
*
|
|
215
|
+
* @param options The options.
|
|
216
|
+
*/
|
|
103
217
|
export declare const IsEmail: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
218
|
+
/**
|
|
219
|
+
* Provides the is fqdn value.
|
|
220
|
+
*
|
|
221
|
+
* @param options The options.
|
|
222
|
+
*/
|
|
104
223
|
export declare const IsFQDN: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
224
|
+
/**
|
|
225
|
+
* Provides the is hex color value.
|
|
226
|
+
*
|
|
227
|
+
* @param options The options.
|
|
228
|
+
*/
|
|
105
229
|
export declare const IsHexColor: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
230
|
+
/**
|
|
231
|
+
* Provides the is hexadecimal value.
|
|
232
|
+
*
|
|
233
|
+
* @param options The options.
|
|
234
|
+
*/
|
|
106
235
|
export declare const IsHexadecimal: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
236
|
+
/**
|
|
237
|
+
* Provides the is json value.
|
|
238
|
+
*
|
|
239
|
+
* @param options The options.
|
|
240
|
+
*/
|
|
107
241
|
export declare const IsJSON: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
242
|
+
/**
|
|
243
|
+
* Provides the is jwt value.
|
|
244
|
+
*
|
|
245
|
+
* @param options The options.
|
|
246
|
+
*/
|
|
108
247
|
export declare const IsJWT: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
248
|
+
/**
|
|
249
|
+
* Provides the is locale value.
|
|
250
|
+
*
|
|
251
|
+
* @param options The options.
|
|
252
|
+
*/
|
|
109
253
|
export declare const IsLocale: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
254
|
+
/**
|
|
255
|
+
* Provides the is lowercase value.
|
|
256
|
+
*
|
|
257
|
+
* @param options The options.
|
|
258
|
+
*/
|
|
110
259
|
export declare const IsLowercase: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
260
|
+
/**
|
|
261
|
+
* Provides the is magnet uri value.
|
|
262
|
+
*
|
|
263
|
+
* @param options The options.
|
|
264
|
+
*/
|
|
111
265
|
export declare const IsMagnetURI: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
266
|
+
/**
|
|
267
|
+
* Provides the is mime type value.
|
|
268
|
+
*
|
|
269
|
+
* @param options The options.
|
|
270
|
+
*/
|
|
112
271
|
export declare const IsMimeType: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
272
|
+
/**
|
|
273
|
+
* Provides the is mongo id value.
|
|
274
|
+
*
|
|
275
|
+
* @param options The options.
|
|
276
|
+
*/
|
|
113
277
|
export declare const IsMongoId: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
278
|
+
/**
|
|
279
|
+
* Provides the is number string value.
|
|
280
|
+
*
|
|
281
|
+
* @param options The options.
|
|
282
|
+
*/
|
|
114
283
|
export declare const IsNumberString: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
284
|
+
/**
|
|
285
|
+
* Provides the is port value.
|
|
286
|
+
*
|
|
287
|
+
* @param options The options.
|
|
288
|
+
*/
|
|
115
289
|
export declare const IsPort: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
290
|
+
/**
|
|
291
|
+
* Provides the is rfc3339 value.
|
|
292
|
+
*
|
|
293
|
+
* @param options The options.
|
|
294
|
+
*/
|
|
116
295
|
export declare const IsRFC3339: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
296
|
+
/**
|
|
297
|
+
* Provides the is sem ver value.
|
|
298
|
+
*
|
|
299
|
+
* @param options The options.
|
|
300
|
+
*/
|
|
117
301
|
export declare const IsSemVer: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
302
|
+
/**
|
|
303
|
+
* Provides the is uppercase value.
|
|
304
|
+
*
|
|
305
|
+
* @param options The options.
|
|
306
|
+
*/
|
|
118
307
|
export declare const IsUppercase: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
308
|
+
/**
|
|
309
|
+
* Provides the is iso8601 value.
|
|
310
|
+
*
|
|
311
|
+
* @param options The options.
|
|
312
|
+
*/
|
|
119
313
|
export declare const IsISO8601: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
314
|
+
/**
|
|
315
|
+
* Provides the is latitude value.
|
|
316
|
+
*
|
|
317
|
+
* @param options The options.
|
|
318
|
+
*/
|
|
120
319
|
export declare const IsLatitude: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
320
|
+
/**
|
|
321
|
+
* Provides the is longitude value.
|
|
322
|
+
*
|
|
323
|
+
* @param options The options.
|
|
324
|
+
*/
|
|
121
325
|
export declare const IsLongitude: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
326
|
+
/**
|
|
327
|
+
* Provides the is lat long value.
|
|
328
|
+
*
|
|
329
|
+
* @param options The options.
|
|
330
|
+
*/
|
|
122
331
|
export declare const IsLatLong: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
123
|
-
/**
|
|
332
|
+
/**
|
|
333
|
+
* Validates that a value is an IPv4/IPv6 address.
|
|
334
|
+
*
|
|
335
|
+
* @param version The version.
|
|
336
|
+
* @param options The options.
|
|
337
|
+
* @returns The is ip result.
|
|
338
|
+
*/
|
|
124
339
|
export declare function IsIP(version?: '4' | '6' | '4_or_6', options?: ValidationDecoratorOptions): FieldDecoratorFn;
|
|
125
|
-
/**
|
|
340
|
+
/**
|
|
341
|
+
* Validates that a value is an ISBN string.
|
|
342
|
+
*
|
|
343
|
+
* @param version The version.
|
|
344
|
+
* @param options The options.
|
|
345
|
+
* @returns The is isbn result.
|
|
346
|
+
*/
|
|
126
347
|
export declare function IsISBN(version?: 10 | 13, options?: ValidationDecoratorOptions): FieldDecoratorFn;
|
|
348
|
+
/**
|
|
349
|
+
* Is issn.
|
|
350
|
+
*
|
|
351
|
+
* @param options The options.
|
|
352
|
+
* @returns The is issn result.
|
|
353
|
+
*/
|
|
127
354
|
export declare function IsISSN(options?: ValidationDecoratorOptions): FieldDecoratorFn;
|
|
355
|
+
/**
|
|
356
|
+
* Is mobile phone.
|
|
357
|
+
*
|
|
358
|
+
* @param locale The locale.
|
|
359
|
+
* @param options The options.
|
|
360
|
+
* @returns The is mobile phone result.
|
|
361
|
+
*/
|
|
128
362
|
export declare function IsMobilePhone(locale?: string | readonly string[], options?: ValidationDecoratorOptions): FieldDecoratorFn;
|
|
363
|
+
/**
|
|
364
|
+
* Is postal code.
|
|
365
|
+
*
|
|
366
|
+
* @param locale The locale.
|
|
367
|
+
* @param options The options.
|
|
368
|
+
* @returns The is postal code result.
|
|
369
|
+
*/
|
|
129
370
|
export declare function IsPostalCode(locale?: string, options?: ValidationDecoratorOptions): FieldDecoratorFn;
|
|
371
|
+
/**
|
|
372
|
+
* Is rgb color.
|
|
373
|
+
*
|
|
374
|
+
* @param includePercentValues The include percent values.
|
|
375
|
+
* @param options The options.
|
|
376
|
+
* @returns The is rgb color result.
|
|
377
|
+
*/
|
|
130
378
|
export declare function IsRgbColor(includePercentValues?: boolean, options?: ValidationDecoratorOptions): FieldDecoratorFn;
|
|
379
|
+
/**
|
|
380
|
+
* Is url.
|
|
381
|
+
*
|
|
382
|
+
* @param options The options.
|
|
383
|
+
* @returns The is url result.
|
|
384
|
+
*/
|
|
131
385
|
export declare function IsUrl(options?: ValidationDecoratorOptions): FieldDecoratorFn;
|
|
386
|
+
/**
|
|
387
|
+
* Is uuid.
|
|
388
|
+
*
|
|
389
|
+
* @param version The version.
|
|
390
|
+
* @param options The options.
|
|
391
|
+
* @returns The is uuid result.
|
|
392
|
+
*/
|
|
132
393
|
export declare function IsUUID(version?: '3' | '4' | '5' | 'all', options?: ValidationDecoratorOptions): FieldDecoratorFn;
|
|
394
|
+
/**
|
|
395
|
+
* Is currency.
|
|
396
|
+
*
|
|
397
|
+
* @param options The options.
|
|
398
|
+
* @returns The is currency result.
|
|
399
|
+
*/
|
|
133
400
|
export declare function IsCurrency(options?: ValidationDecoratorOptions): FieldDecoratorFn;
|
|
401
|
+
/**
|
|
402
|
+
* Provides the array contains value.
|
|
403
|
+
*/
|
|
134
404
|
export declare const ArrayContains: (values: readonly unknown[], options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
405
|
+
/**
|
|
406
|
+
* Provides the array not contains value.
|
|
407
|
+
*/
|
|
135
408
|
export declare const ArrayNotContains: (values: readonly unknown[], options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
409
|
+
/**
|
|
410
|
+
* Provides the array not empty value.
|
|
411
|
+
*/
|
|
136
412
|
export declare const ArrayNotEmpty: (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
413
|
+
/**
|
|
414
|
+
* Provides the array min size value.
|
|
415
|
+
*/
|
|
137
416
|
export declare const ArrayMinSize: (value: number, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
417
|
+
/**
|
|
418
|
+
* Provides the array max size value.
|
|
419
|
+
*/
|
|
138
420
|
export declare const ArrayMaxSize: (value: number, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
139
421
|
/**
|
|
140
422
|
* Ensures all values in the array are unique, optionally by selector.
|
package/dist/decorators.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings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AAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,gBAAgB,CAE5E;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,KAAK,EAAE,OAAO,CAAC,EAAE,0BAA0B,GAAG,gBAAgB,CAEhH;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,gBAAgB,CAEjF;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,yCA5egB,0BAA0B,KAAG,gBA4emE,CAAC;AAC3I;;GAEG;AACH,eAAO,MAAM,gBAAgB,yCAhfa,0BAA0B,KAAG,gBAgfyE,CAAC;AACjJ;;GAEG;AACH,eAAO,MAAM,aAAa,aA5fN,0BAA0B,KAAG,gBA4f+D,CAAC;AACjH;;GAEG;AACH,eAAO,MAAM,YAAY,4BAxgBK,0BAA0B,KAAG,gBAwgBsF,CAAC;AAClJ;;GAEG;AACH,eAAO,MAAM,YAAY,4BA5gBK,0BAA0B,KAAG,gBA4gBsF,CAAC;AAElJ;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,iBAAiB,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,GAAG,0BAA0B,EAC9E,OAAO,CAAC,EAAE,0BAA0B,GACnC,gBAAgB,CAKlB;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,EAAE,OAAO,CAAC,EAAE,gCAAgC,GAAG,gBAAgB,CASrH;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,0BAA0B,GAAG,gBAAgB,CAUlH"}
|
package/dist/decorators.js
CHANGED
|
@@ -125,62 +125,105 @@ export const ValidateIf = (validateIf, options) => createValidationDecorator(()
|
|
|
125
125
|
validateIf,
|
|
126
126
|
...options
|
|
127
127
|
}));
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Provides the is defined value.
|
|
131
|
+
*/
|
|
128
132
|
export const IsDefined = createFlagValidationDecorator(options => ({
|
|
129
133
|
kind: 'defined',
|
|
130
134
|
...options
|
|
131
135
|
}));
|
|
136
|
+
/**
|
|
137
|
+
* Provides the is optional value.
|
|
138
|
+
*/
|
|
132
139
|
export const IsOptional = createFlagValidationDecorator(options => ({
|
|
133
140
|
kind: 'optional',
|
|
134
141
|
...options
|
|
135
142
|
}));
|
|
143
|
+
/**
|
|
144
|
+
* Provides the equals value.
|
|
145
|
+
*/
|
|
136
146
|
export const Equals = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
137
147
|
kind: 'equals',
|
|
138
148
|
value,
|
|
139
149
|
...options
|
|
140
150
|
}));
|
|
151
|
+
/**
|
|
152
|
+
* Provides the not equals value.
|
|
153
|
+
*/
|
|
141
154
|
export const NotEquals = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
142
155
|
kind: 'notEquals',
|
|
143
156
|
value,
|
|
144
157
|
...options
|
|
145
158
|
}));
|
|
159
|
+
/**
|
|
160
|
+
* Provides the is empty value.
|
|
161
|
+
*/
|
|
146
162
|
export const IsEmpty = createFlagValidationDecorator(options => ({
|
|
147
163
|
kind: 'empty',
|
|
148
164
|
...options
|
|
149
165
|
}));
|
|
166
|
+
/**
|
|
167
|
+
* Provides the is not empty value.
|
|
168
|
+
*/
|
|
150
169
|
export const IsNotEmpty = createFlagValidationDecorator(options => ({
|
|
151
170
|
kind: 'notEmpty',
|
|
152
171
|
...options
|
|
153
172
|
}));
|
|
173
|
+
/**
|
|
174
|
+
* Provides the is in value.
|
|
175
|
+
*/
|
|
154
176
|
export const IsIn = createArrayValidationDecorator((values, options) => ({
|
|
155
177
|
kind: 'in',
|
|
156
178
|
values,
|
|
157
179
|
...options
|
|
158
180
|
}));
|
|
181
|
+
/**
|
|
182
|
+
* Provides the is not in value.
|
|
183
|
+
*/
|
|
159
184
|
export const IsNotIn = createArrayValidationDecorator((values, options) => ({
|
|
160
185
|
kind: 'notIn',
|
|
161
186
|
values,
|
|
162
187
|
...options
|
|
163
188
|
}));
|
|
189
|
+
/**
|
|
190
|
+
* Provides the is date value.
|
|
191
|
+
*/
|
|
164
192
|
export const IsDate = createFlagValidationDecorator(options => ({
|
|
165
193
|
kind: 'date',
|
|
166
194
|
...options
|
|
167
195
|
}));
|
|
196
|
+
/**
|
|
197
|
+
* Provides the is array value.
|
|
198
|
+
*/
|
|
168
199
|
export const IsArray = createFlagValidationDecorator(options => ({
|
|
169
200
|
kind: 'array',
|
|
170
201
|
...options
|
|
171
202
|
}));
|
|
203
|
+
/**
|
|
204
|
+
* Provides the is object value.
|
|
205
|
+
*/
|
|
172
206
|
export const IsObject = createFlagValidationDecorator(options => ({
|
|
173
207
|
kind: 'object',
|
|
174
208
|
...options
|
|
175
209
|
}));
|
|
210
|
+
/**
|
|
211
|
+
* Provides the is int value.
|
|
212
|
+
*/
|
|
176
213
|
export const IsInt = createFlagValidationDecorator(options => ({
|
|
177
214
|
kind: 'int',
|
|
178
215
|
...options
|
|
179
216
|
}));
|
|
217
|
+
/**
|
|
218
|
+
* Provides the is positive value.
|
|
219
|
+
*/
|
|
180
220
|
export const IsPositive = createFlagValidationDecorator(options => ({
|
|
181
221
|
kind: 'positive',
|
|
182
222
|
...options
|
|
183
223
|
}));
|
|
224
|
+
/**
|
|
225
|
+
* Provides the is negative value.
|
|
226
|
+
*/
|
|
184
227
|
export const IsNegative = createFlagValidationDecorator(options => ({
|
|
185
228
|
kind: 'negative',
|
|
186
229
|
...options
|
|
@@ -201,36 +244,58 @@ export function IsEnum(values, options) {
|
|
|
201
244
|
...options
|
|
202
245
|
}));
|
|
203
246
|
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Provides the is divisible by value.
|
|
250
|
+
*/
|
|
204
251
|
export const IsDivisibleBy = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
205
252
|
kind: 'divisibleBy',
|
|
206
253
|
value,
|
|
207
254
|
...options
|
|
208
255
|
}));
|
|
256
|
+
/**
|
|
257
|
+
* Provides the min value.
|
|
258
|
+
*/
|
|
209
259
|
export const Min = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
210
260
|
kind: 'min',
|
|
211
261
|
value,
|
|
212
262
|
...options
|
|
213
263
|
}));
|
|
264
|
+
/**
|
|
265
|
+
* Provides the max value.
|
|
266
|
+
*/
|
|
214
267
|
export const Max = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
215
268
|
kind: 'max',
|
|
216
269
|
value,
|
|
217
270
|
...options
|
|
218
271
|
}));
|
|
272
|
+
/**
|
|
273
|
+
* Provides the min date value.
|
|
274
|
+
*/
|
|
219
275
|
export const MinDate = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
220
276
|
kind: 'minDate',
|
|
221
277
|
value,
|
|
222
278
|
...options
|
|
223
279
|
}));
|
|
280
|
+
/**
|
|
281
|
+
* Provides the max date value.
|
|
282
|
+
*/
|
|
224
283
|
export const MaxDate = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
225
284
|
kind: 'maxDate',
|
|
226
285
|
value,
|
|
227
286
|
...options
|
|
228
287
|
}));
|
|
288
|
+
/**
|
|
289
|
+
* Provides the contains value.
|
|
290
|
+
*/
|
|
229
291
|
export const Contains = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
230
292
|
kind: 'contains',
|
|
231
293
|
value,
|
|
232
294
|
...options
|
|
233
295
|
}));
|
|
296
|
+
/**
|
|
297
|
+
* Provides the not contains value.
|
|
298
|
+
*/
|
|
234
299
|
export const NotContains = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
235
300
|
kind: 'notContains',
|
|
236
301
|
value,
|
|
@@ -268,11 +333,18 @@ export function ValidateNested(dto, options) {
|
|
|
268
333
|
...options
|
|
269
334
|
}));
|
|
270
335
|
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Provides the min length value.
|
|
339
|
+
*/
|
|
271
340
|
export const MinLength = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
272
341
|
kind: 'minLength',
|
|
273
342
|
value,
|
|
274
343
|
...options
|
|
275
344
|
}));
|
|
345
|
+
/**
|
|
346
|
+
* Provides the max length value.
|
|
347
|
+
*/
|
|
276
348
|
export const MaxLength = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
277
349
|
kind: 'maxLength',
|
|
278
350
|
value,
|
|
@@ -304,84 +376,306 @@ export function Matches(pattern, modifiersOrOptions, options) {
|
|
|
304
376
|
...resolvedOptions
|
|
305
377
|
}));
|
|
306
378
|
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Provides the is alpha value.
|
|
382
|
+
*
|
|
383
|
+
* @param options The options.
|
|
384
|
+
*/
|
|
307
385
|
export const IsAlpha = options => createValidatorJsDecorator('alpha')(undefined, options);
|
|
386
|
+
/**
|
|
387
|
+
* Provides the is alphanumeric value.
|
|
388
|
+
*
|
|
389
|
+
* @param options The options.
|
|
390
|
+
*/
|
|
308
391
|
export const IsAlphanumeric = options => createValidatorJsDecorator('alphanumeric')(undefined, options);
|
|
392
|
+
/**
|
|
393
|
+
* Provides the is ascii value.
|
|
394
|
+
*
|
|
395
|
+
* @param options The options.
|
|
396
|
+
*/
|
|
309
397
|
export const IsAscii = options => createValidatorJsDecorator('ascii')(undefined, options);
|
|
398
|
+
/**
|
|
399
|
+
* Provides the is base64 value.
|
|
400
|
+
*
|
|
401
|
+
* @param options The options.
|
|
402
|
+
*/
|
|
310
403
|
export const IsBase64 = options => createValidatorJsDecorator('base64')(undefined, options);
|
|
404
|
+
/**
|
|
405
|
+
* Provides the is boolean string value.
|
|
406
|
+
*
|
|
407
|
+
* @param options The options.
|
|
408
|
+
*/
|
|
311
409
|
export const IsBooleanString = options => createValidatorJsDecorator('booleanString')(undefined, options);
|
|
410
|
+
/**
|
|
411
|
+
* Provides the is data uri value.
|
|
412
|
+
*
|
|
413
|
+
* @param options The options.
|
|
414
|
+
*/
|
|
312
415
|
export const IsDataURI = options => createValidatorJsDecorator('dataURI')(undefined, options);
|
|
416
|
+
/**
|
|
417
|
+
* Provides the is date string value.
|
|
418
|
+
*
|
|
419
|
+
* @param options The options.
|
|
420
|
+
*/
|
|
313
421
|
export const IsDateString = options => createValidatorJsDecorator('dateString')(undefined, options);
|
|
422
|
+
/**
|
|
423
|
+
* Provides the is decimal value.
|
|
424
|
+
*
|
|
425
|
+
* @param options The options.
|
|
426
|
+
*/
|
|
314
427
|
export const IsDecimal = options => createValidatorJsDecorator('decimal')(undefined, options);
|
|
428
|
+
/**
|
|
429
|
+
* Provides the is email value.
|
|
430
|
+
*
|
|
431
|
+
* @param options The options.
|
|
432
|
+
*/
|
|
315
433
|
export const IsEmail = options => createValidatorJsDecorator('email')(undefined, options);
|
|
434
|
+
/**
|
|
435
|
+
* Provides the is fqdn value.
|
|
436
|
+
*
|
|
437
|
+
* @param options The options.
|
|
438
|
+
*/
|
|
316
439
|
export const IsFQDN = options => createValidatorJsDecorator('fqdn')(undefined, options);
|
|
440
|
+
/**
|
|
441
|
+
* Provides the is hex color value.
|
|
442
|
+
*
|
|
443
|
+
* @param options The options.
|
|
444
|
+
*/
|
|
317
445
|
export const IsHexColor = options => createValidatorJsDecorator('hexColor')(undefined, options);
|
|
446
|
+
/**
|
|
447
|
+
* Provides the is hexadecimal value.
|
|
448
|
+
*
|
|
449
|
+
* @param options The options.
|
|
450
|
+
*/
|
|
318
451
|
export const IsHexadecimal = options => createValidatorJsDecorator('hexadecimal')(undefined, options);
|
|
452
|
+
/**
|
|
453
|
+
* Provides the is json value.
|
|
454
|
+
*
|
|
455
|
+
* @param options The options.
|
|
456
|
+
*/
|
|
319
457
|
export const IsJSON = options => createValidatorJsDecorator('json')(undefined, options);
|
|
458
|
+
/**
|
|
459
|
+
* Provides the is jwt value.
|
|
460
|
+
*
|
|
461
|
+
* @param options The options.
|
|
462
|
+
*/
|
|
320
463
|
export const IsJWT = options => createValidatorJsDecorator('jwt')(undefined, options);
|
|
464
|
+
/**
|
|
465
|
+
* Provides the is locale value.
|
|
466
|
+
*
|
|
467
|
+
* @param options The options.
|
|
468
|
+
*/
|
|
321
469
|
export const IsLocale = options => createValidatorJsDecorator('locale')(undefined, options);
|
|
470
|
+
/**
|
|
471
|
+
* Provides the is lowercase value.
|
|
472
|
+
*
|
|
473
|
+
* @param options The options.
|
|
474
|
+
*/
|
|
322
475
|
export const IsLowercase = options => createValidatorJsDecorator('lowercase')(undefined, options);
|
|
476
|
+
/**
|
|
477
|
+
* Provides the is magnet uri value.
|
|
478
|
+
*
|
|
479
|
+
* @param options The options.
|
|
480
|
+
*/
|
|
323
481
|
export const IsMagnetURI = options => createValidatorJsDecorator('magnetURI')(undefined, options);
|
|
482
|
+
/**
|
|
483
|
+
* Provides the is mime type value.
|
|
484
|
+
*
|
|
485
|
+
* @param options The options.
|
|
486
|
+
*/
|
|
324
487
|
export const IsMimeType = options => createValidatorJsDecorator('mimeType')(undefined, options);
|
|
488
|
+
/**
|
|
489
|
+
* Provides the is mongo id value.
|
|
490
|
+
*
|
|
491
|
+
* @param options The options.
|
|
492
|
+
*/
|
|
325
493
|
export const IsMongoId = options => createValidatorJsDecorator('mongoId')(undefined, options);
|
|
494
|
+
/**
|
|
495
|
+
* Provides the is number string value.
|
|
496
|
+
*
|
|
497
|
+
* @param options The options.
|
|
498
|
+
*/
|
|
326
499
|
export const IsNumberString = options => createValidatorJsDecorator('numberString')(undefined, options);
|
|
500
|
+
/**
|
|
501
|
+
* Provides the is port value.
|
|
502
|
+
*
|
|
503
|
+
* @param options The options.
|
|
504
|
+
*/
|
|
327
505
|
export const IsPort = options => createValidatorJsDecorator('port')(undefined, options);
|
|
506
|
+
/**
|
|
507
|
+
* Provides the is rfc3339 value.
|
|
508
|
+
*
|
|
509
|
+
* @param options The options.
|
|
510
|
+
*/
|
|
328
511
|
export const IsRFC3339 = options => createValidatorJsDecorator('rfc3339')(undefined, options);
|
|
512
|
+
/**
|
|
513
|
+
* Provides the is sem ver value.
|
|
514
|
+
*
|
|
515
|
+
* @param options The options.
|
|
516
|
+
*/
|
|
329
517
|
export const IsSemVer = options => createValidatorJsDecorator('semVer')(undefined, options);
|
|
518
|
+
/**
|
|
519
|
+
* Provides the is uppercase value.
|
|
520
|
+
*
|
|
521
|
+
* @param options The options.
|
|
522
|
+
*/
|
|
330
523
|
export const IsUppercase = options => createValidatorJsDecorator('uppercase')(undefined, options);
|
|
524
|
+
/**
|
|
525
|
+
* Provides the is iso8601 value.
|
|
526
|
+
*
|
|
527
|
+
* @param options The options.
|
|
528
|
+
*/
|
|
331
529
|
export const IsISO8601 = options => createValidatorJsDecorator('iso8601')(undefined, options);
|
|
530
|
+
/**
|
|
531
|
+
* Provides the is latitude value.
|
|
532
|
+
*
|
|
533
|
+
* @param options The options.
|
|
534
|
+
*/
|
|
332
535
|
export const IsLatitude = options => createValidatorJsDecorator('latitude')(undefined, options);
|
|
536
|
+
/**
|
|
537
|
+
* Provides the is longitude value.
|
|
538
|
+
*
|
|
539
|
+
* @param options The options.
|
|
540
|
+
*/
|
|
333
541
|
export const IsLongitude = options => createValidatorJsDecorator('longitude')(undefined, options);
|
|
542
|
+
/**
|
|
543
|
+
* Provides the is lat long value.
|
|
544
|
+
*
|
|
545
|
+
* @param options The options.
|
|
546
|
+
*/
|
|
334
547
|
export const IsLatLong = options => createValidatorJsDecorator('latLong')(undefined, options);
|
|
335
548
|
|
|
336
|
-
/**
|
|
549
|
+
/**
|
|
550
|
+
* Validates that a value is an IPv4/IPv6 address.
|
|
551
|
+
*
|
|
552
|
+
* @param version The version.
|
|
553
|
+
* @param options The options.
|
|
554
|
+
* @returns The is ip result.
|
|
555
|
+
*/
|
|
337
556
|
export function IsIP(version, options) {
|
|
338
557
|
return createValidatorJsDecorator('ip')(version ? [version] : undefined, options);
|
|
339
558
|
}
|
|
340
559
|
|
|
341
|
-
/**
|
|
560
|
+
/**
|
|
561
|
+
* Validates that a value is an ISBN string.
|
|
562
|
+
*
|
|
563
|
+
* @param version The version.
|
|
564
|
+
* @param options The options.
|
|
565
|
+
* @returns The is isbn result.
|
|
566
|
+
*/
|
|
342
567
|
export function IsISBN(version, options) {
|
|
343
568
|
return createValidatorJsDecorator('isbn')(version ? [String(version)] : undefined, options);
|
|
344
569
|
}
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Is issn.
|
|
573
|
+
*
|
|
574
|
+
* @param options The options.
|
|
575
|
+
* @returns The is issn result.
|
|
576
|
+
*/
|
|
345
577
|
export function IsISSN(options) {
|
|
346
578
|
return createValidatorJsDecorator('issn')(undefined, options);
|
|
347
579
|
}
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* Is mobile phone.
|
|
583
|
+
*
|
|
584
|
+
* @param locale The locale.
|
|
585
|
+
* @param options The options.
|
|
586
|
+
* @returns The is mobile phone result.
|
|
587
|
+
*/
|
|
348
588
|
export function IsMobilePhone(locale, options) {
|
|
349
589
|
return createValidatorJsDecorator('mobilePhone')(locale ? [locale] : undefined, options);
|
|
350
590
|
}
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Is postal code.
|
|
594
|
+
*
|
|
595
|
+
* @param locale The locale.
|
|
596
|
+
* @param options The options.
|
|
597
|
+
* @returns The is postal code result.
|
|
598
|
+
*/
|
|
351
599
|
export function IsPostalCode(locale, options) {
|
|
352
600
|
return createValidatorJsDecorator('postalCode')(locale ? [locale] : undefined, options);
|
|
353
601
|
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* Is rgb color.
|
|
605
|
+
*
|
|
606
|
+
* @param includePercentValues The include percent values.
|
|
607
|
+
* @param options The options.
|
|
608
|
+
* @returns The is rgb color result.
|
|
609
|
+
*/
|
|
354
610
|
export function IsRgbColor(includePercentValues, options) {
|
|
355
611
|
return createValidatorJsDecorator('rgbColor')(includePercentValues === undefined ? undefined : [includePercentValues], options);
|
|
356
612
|
}
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Is url.
|
|
616
|
+
*
|
|
617
|
+
* @param options The options.
|
|
618
|
+
* @returns The is url result.
|
|
619
|
+
*/
|
|
357
620
|
export function IsUrl(options) {
|
|
358
621
|
return createValidatorJsDecorator('url')(undefined, options);
|
|
359
622
|
}
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* Is uuid.
|
|
626
|
+
*
|
|
627
|
+
* @param version The version.
|
|
628
|
+
* @param options The options.
|
|
629
|
+
* @returns The is uuid result.
|
|
630
|
+
*/
|
|
360
631
|
export function IsUUID(version, options) {
|
|
361
632
|
return createValidatorJsDecorator('uuid')(version ? [version] : undefined, options);
|
|
362
633
|
}
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* Is currency.
|
|
637
|
+
*
|
|
638
|
+
* @param options The options.
|
|
639
|
+
* @returns The is currency result.
|
|
640
|
+
*/
|
|
363
641
|
export function IsCurrency(options) {
|
|
364
642
|
return createValidatorJsDecorator('currency')(undefined, options);
|
|
365
643
|
}
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Provides the array contains value.
|
|
647
|
+
*/
|
|
366
648
|
export const ArrayContains = createArrayValidationDecorator((values, options) => ({
|
|
367
649
|
kind: 'arrayContains',
|
|
368
650
|
values,
|
|
369
651
|
...options
|
|
370
652
|
}));
|
|
653
|
+
/**
|
|
654
|
+
* Provides the array not contains value.
|
|
655
|
+
*/
|
|
371
656
|
export const ArrayNotContains = createArrayValidationDecorator((values, options) => ({
|
|
372
657
|
kind: 'arrayNotContains',
|
|
373
658
|
values,
|
|
374
659
|
...options
|
|
375
660
|
}));
|
|
661
|
+
/**
|
|
662
|
+
* Provides the array not empty value.
|
|
663
|
+
*/
|
|
376
664
|
export const ArrayNotEmpty = createFlagValidationDecorator(options => ({
|
|
377
665
|
kind: 'arrayNotEmpty',
|
|
378
666
|
...options
|
|
379
667
|
}));
|
|
668
|
+
/**
|
|
669
|
+
* Provides the array min size value.
|
|
670
|
+
*/
|
|
380
671
|
export const ArrayMinSize = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
381
672
|
kind: 'arrayMinSize',
|
|
382
673
|
value,
|
|
383
674
|
...options
|
|
384
675
|
}));
|
|
676
|
+
/**
|
|
677
|
+
* Provides the array max size value.
|
|
678
|
+
*/
|
|
385
679
|
export const ArrayMaxSize = createValidationOptionsWithConfigDecorator((value, options) => ({
|
|
386
680
|
kind: 'arrayMaxSize',
|
|
387
681
|
value,
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { ValidationIssue } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the dto validation error.
|
|
4
|
+
*/
|
|
2
5
|
export declare class DtoValidationError extends Error {
|
|
3
6
|
readonly issues: readonly ValidationIssue[];
|
|
4
7
|
constructor(message: string, issues: readonly ValidationIssue[]);
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,qBAAa,kBAAmB,SAAQ,KAAK;IAGzC,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE;gBAD3C,OAAO,EAAE,MAAM,EACN,MAAM,EAAE,SAAS,eAAe,EAAE;CAM9C"}
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAGzC,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE;gBAD3C,OAAO,EAAE,MAAM,EACN,MAAM,EAAE,SAAS,eAAe,EAAE;CAM9C"}
|
package/dist/errors.js
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,YAAY,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
import type { CustomClassValidator } from '@fluojs/core/internal';
|
|
3
|
+
/**
|
|
4
|
+
* Standard Schema v1-compatible validator accepted by `ValidateClass`.
|
|
5
|
+
*
|
|
6
|
+
* @typeParam Input Input DTO shape consumed by the schema validator.
|
|
7
|
+
* @typeParam Output Output DTO shape produced by the schema validator.
|
|
8
|
+
*/
|
|
3
9
|
export type StandardSchemaV1Like<Input = unknown, Output = Input> = StandardSchemaV1<Input, Output>;
|
|
10
|
+
/**
|
|
11
|
+
* Detect whether a value implements the Standard Schema v1 contract.
|
|
12
|
+
*
|
|
13
|
+
* @param value Candidate schema value supplied to validation decorators.
|
|
14
|
+
* @returns `true` when the candidate exposes a Standard Schema v1 validator.
|
|
15
|
+
*/
|
|
4
16
|
export declare function isStandardSchemaLike(value: unknown): value is StandardSchemaV1Like;
|
|
17
|
+
/**
|
|
18
|
+
* Adapt a Standard Schema validator to fluo class-level validation.
|
|
19
|
+
*
|
|
20
|
+
* @param schema Standard Schema-compatible validator definition.
|
|
21
|
+
* @returns A class validator that reports normalized validation issues.
|
|
22
|
+
*/
|
|
5
23
|
export declare function createClassValidatorFromStandardSchema(schema: StandardSchemaV1Like): CustomClassValidator;
|
|
6
24
|
//# sourceMappingURL=standard-schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard-schema.d.ts","sourceRoot":"","sources":["../src/standard-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAIlE,MAAM,MAAM,oBAAoB,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,KAAK,IAAI,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AA0CpG,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB,CAkBlF;AA4CD,wBAAgB,sCAAsC,CAAC,MAAM,EAAE,oBAAoB,GAAG,oBAAoB,CAgBzG"}
|
|
1
|
+
{"version":3,"file":"standard-schema.d.ts","sourceRoot":"","sources":["../src/standard-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAIlE;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,KAAK,IAAI,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AA0CpG;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB,CAkBlF;AA4CD;;;;;GAKG;AACH,wBAAgB,sCAAsC,CAAC,MAAM,EAAE,oBAAoB,GAAG,oBAAoB,CAgBzG"}
|
package/dist/standard-schema.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard Schema v1-compatible validator accepted by `ValidateClass`.
|
|
3
|
+
*
|
|
4
|
+
* @typeParam Input Input DTO shape consumed by the schema validator.
|
|
5
|
+
* @typeParam Output Output DTO shape produced by the schema validator.
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
function toFieldPath(path) {
|
|
2
9
|
if (!path || path.length === 0) {
|
|
3
10
|
return undefined;
|
|
@@ -21,6 +28,13 @@ function normalizeCode(code, fallback) {
|
|
|
21
28
|
}
|
|
22
29
|
return code.replace(/[^A-Za-z0-9]+/g, '_').replace(/^_+|_+$/g, '').toUpperCase() || fallback;
|
|
23
30
|
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Detect whether a value implements the Standard Schema v1 contract.
|
|
34
|
+
*
|
|
35
|
+
* @param value Candidate schema value supplied to validation decorators.
|
|
36
|
+
* @returns `true` when the candidate exposes a Standard Schema v1 validator.
|
|
37
|
+
*/
|
|
24
38
|
export function isStandardSchemaLike(value) {
|
|
25
39
|
if (typeof value !== 'object' && typeof value !== 'function' || value === null) {
|
|
26
40
|
return false;
|
|
@@ -58,6 +72,13 @@ function toStandardValidationIssue(issue) {
|
|
|
58
72
|
function isStandardSchemaFailureResult(result) {
|
|
59
73
|
return typeof result === 'object' && result !== null && 'issues' in result;
|
|
60
74
|
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Adapt a Standard Schema validator to fluo class-level validation.
|
|
78
|
+
*
|
|
79
|
+
* @param schema Standard Schema-compatible validator definition.
|
|
80
|
+
* @returns A class validator that reports normalized validation issues.
|
|
81
|
+
*/
|
|
61
82
|
export function createClassValidatorFromStandardSchema(schema) {
|
|
62
83
|
return async value => {
|
|
63
84
|
const result = await schema['~standard'].validate(value);
|
package/dist/types.d.ts
CHANGED
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WA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AAC,CAAC;CACzE"}
|
package/dist/validation.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Constructor } from '@fluojs/core';
|
|
2
2
|
import type { Validator } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Represents the default validator.
|
|
5
|
+
*/
|
|
3
6
|
export declare class DefaultValidator implements Validator {
|
|
4
7
|
validate(value: unknown, target: Constructor): Promise<void>;
|
|
5
8
|
materialize<T>(value: unknown, target: Constructor<T>): Promise<T>;
|
package/dist/validation.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,WAAW,EAEZ,MAAM,cAAc,CAAC;AAatB,OAAO,KAAK,EAAmB,SAAS,EAAE,MAAM,YAAY,CAAC;AAgxB7D;;GAEG;AACH,qBAAa,gBAAiB,YAAW,SAAS;IAC1C,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAM5D,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAczE"}
|
package/dist/validation.js
CHANGED
|
@@ -334,10 +334,10 @@ function createNestedDtoInstance(target, rawValue, context) {
|
|
|
334
334
|
if (rawValue instanceof target) {
|
|
335
335
|
return rawValue;
|
|
336
336
|
}
|
|
337
|
-
const instance = new target();
|
|
338
337
|
if (!isPlainObject(rawValue)) {
|
|
339
|
-
return
|
|
338
|
+
return rawValue;
|
|
340
339
|
}
|
|
340
|
+
const instance = new target();
|
|
341
341
|
if (!enterTraversal(rawValue, context)) {
|
|
342
342
|
return rawValue;
|
|
343
343
|
}
|
|
@@ -494,6 +494,12 @@ function buildIssue(fallback, field, source) {
|
|
|
494
494
|
source
|
|
495
495
|
};
|
|
496
496
|
}
|
|
497
|
+
function buildInvalidRootIssue() {
|
|
498
|
+
return {
|
|
499
|
+
code: 'INVALID_DTO',
|
|
500
|
+
message: 'DTO root value must be a plain object.'
|
|
501
|
+
};
|
|
502
|
+
}
|
|
497
503
|
function getRuleValues(value) {
|
|
498
504
|
return getIterableValues(value) ?? [value];
|
|
499
505
|
}
|
|
@@ -634,6 +640,10 @@ async function collectValidationIssuesInternal(target, value, context, traversal
|
|
|
634
640
|
exitTraversal(value, traversal);
|
|
635
641
|
}
|
|
636
642
|
}
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Represents the default validator.
|
|
646
|
+
*/
|
|
637
647
|
export class DefaultValidator {
|
|
638
648
|
async validate(value, target) {
|
|
639
649
|
const issues = await collectValidationIssues(target, value);
|
|
@@ -641,6 +651,9 @@ export class DefaultValidator {
|
|
|
641
651
|
throw new DtoValidationError('Validation failed.', issues);
|
|
642
652
|
}
|
|
643
653
|
async materialize(value, target) {
|
|
654
|
+
if (!(value instanceof target) && !isPlainObject(value)) {
|
|
655
|
+
throw new DtoValidationError('Validation failed.', [buildInvalidRootIssue()]);
|
|
656
|
+
}
|
|
644
657
|
const instance = createNestedDtoInstance(target, value, {
|
|
645
658
|
active: new WeakSet()
|
|
646
659
|
});
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"decorators",
|
|
10
10
|
"schema"
|
|
11
11
|
],
|
|
12
|
-
"version": "1.0.0-beta.
|
|
12
|
+
"version": "1.0.0-beta.2",
|
|
13
13
|
"private": false,
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"repository": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@standard-schema/spec": "^1.1.0",
|
|
44
44
|
"validator": "^13.15.26",
|
|
45
|
-
"@fluojs/core": "^1.0.0-beta.
|
|
45
|
+
"@fluojs/core": "^1.0.0-beta.3"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/validator": "^13.15.10",
|