@fluojs/validation 1.0.0-beta.1 → 1.0.0-beta.3
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 +75 -57
- package/README.md +44 -4
- package/dist/decorators.d.ts +284 -2
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +298 -4
- 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
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
fluo를 위한 입력값 검증 데코레이터, Mapped DTO 헬퍼 및 검증 엔진입니다.
|
|
6
6
|
|
|
7
|
-
`@fluojs/validation`은 애플리케이션의 **입력 경계(Input Boundary)**를 담당합니다. 가공되지 않은(untyped) raw 데이터를 검증이 완료된 타입 기반 클래스 인스턴스(DTO)로 변환하는 강력한 데코레이터 세트와 실체화(Materialization) 엔진을 제공합니다. 이를 통해 비즈니스 로직에 도달하기 전 데이터의 무결성을 보장합니다.
|
|
8
|
-
|
|
9
7
|
## 목차
|
|
10
8
|
|
|
11
9
|
- [설치](#설치)
|
|
@@ -24,115 +22,135 @@ pnpm add @fluojs/validation
|
|
|
24
22
|
|
|
25
23
|
## 사용 시점
|
|
26
24
|
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
- Zod나 Valibot 같은
|
|
25
|
+
- raw request payload를 비즈니스 로직에 도달하기 전에 검증된 DTO 인스턴스로 바꿔야 할 때
|
|
26
|
+
- 컨트롤러나 서비스에서 ad hoc parsing 대신 class 기반 검증 규칙을 쓰고 싶을 때
|
|
27
|
+
- `PickType`, `PartialType`, `IntersectionType` 같은 metadata-preserving mapped DTO helper가 필요할 때
|
|
28
|
+
- `@ValidateClass(...)`로 Zod나 Valibot 같은 Standard Schema validator를 붙이고 싶을 때
|
|
31
29
|
|
|
32
30
|
## 빠른 시작
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
```typescript
|
|
37
|
-
import { IsEmail, IsString, MinLength, DefaultValidator } from '@fluojs/validation';
|
|
32
|
+
```ts
|
|
33
|
+
import { DefaultValidator, DtoValidationError, IsEmail, IsString, MinLength } from '@fluojs/validation';
|
|
38
34
|
|
|
39
35
|
class CreateUserDto {
|
|
40
36
|
@IsEmail()
|
|
41
|
-
email
|
|
37
|
+
email = '';
|
|
42
38
|
|
|
43
39
|
@IsString()
|
|
44
40
|
@MinLength(2)
|
|
45
|
-
name
|
|
41
|
+
name = '';
|
|
46
42
|
}
|
|
47
43
|
|
|
48
44
|
const validator = new DefaultValidator();
|
|
49
|
-
const rawData = { email: 'test@example.com', name: 'Ko' };
|
|
50
|
-
|
|
51
|
-
// materialize()는 CreateUserDto의 인스턴스를 생성하고 검증을 수행합니다.
|
|
52
|
-
const user = await validator.materialize(rawData, CreateUserDto);
|
|
53
45
|
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
try {
|
|
47
|
+
const dto = await validator.materialize(
|
|
48
|
+
{ email: 'hello@example.com', name: 'fluo' },
|
|
49
|
+
CreateUserDto,
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
console.log(dto instanceof CreateUserDto);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
if (error instanceof DtoValidationError) {
|
|
55
|
+
console.log(error.issues);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
56
58
|
```
|
|
57
59
|
|
|
58
60
|
## 주요 패턴
|
|
59
61
|
|
|
60
|
-
###
|
|
62
|
+
### `materialize()` vs `validate()`
|
|
61
63
|
|
|
62
64
|
- **`materialize<T>(value, target)`**: **입력 처리**에 가장 적합합니다. plain 객체를 받아 대상 클래스의 인스턴스를 생성하고, 값을 복사하며, 중첩된 DTO를 재귀적으로 처리한 후 모든 검증 규칙을 실행합니다.
|
|
63
|
-
- **`validate(instance, target)`**: **기존 객체 확인**에 적합합니다. 이미 생성된
|
|
65
|
+
- **`validate(instance, target)`**: **기존 루트 객체 확인**에 적합합니다. 이미 생성된 루트 값에 대해 검증 규칙을 실행하며, plain 객체인 `@ValidateNested(...)` 값은 중첩 DTO 규칙을 실행하기 위해 임시로 실체화할 수 있습니다. 이 임시 실체화는 호출자가 넘긴 속성 값을 대체하지 않습니다.
|
|
66
|
+
|
|
67
|
+
`materialize()`는 plain 입력 객체의 안전한 own enumerable 속성을 복사하고,
|
|
68
|
+
DTO 바인딩 메타데이터를 적용한 뒤 `@ValidateNested(...)` 필드를 재귀적으로
|
|
69
|
+
실체화합니다. 어떤 요청 소스를 선택하고 스칼라 값을 변환할지는 transport 또는
|
|
70
|
+
binder가 검증 전에 담당한다는 request-pipeline 계약을 유지합니다.
|
|
71
|
+
`materialize()`에 넘기는 루트 값은 plain 객체이거나 대상 DTO 인스턴스여야 합니다.
|
|
72
|
+
문자열, 배열, `null` 같은 잘못된 루트 값은 대상 DTO 생성자나 필드 initializer가
|
|
73
|
+
실행되기 전에 거부됩니다.
|
|
74
|
+
|
|
75
|
+
### 검증 이슈 형태
|
|
76
|
+
|
|
77
|
+
`DtoValidationError.issues`는 request-pipeline 오류 상세에 사용하는 안정적인 DTO입니다.
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
type ValidationIssue = {
|
|
81
|
+
code: string;
|
|
82
|
+
field?: string;
|
|
83
|
+
message: string;
|
|
84
|
+
source?: 'path' | 'query' | 'header' | 'cookie' | 'body';
|
|
85
|
+
};
|
|
86
|
+
```
|
|
64
87
|
|
|
65
|
-
|
|
88
|
+
중첩 DTO는 `address.city`, `items[0].name` 같은 dot path와 collection index를
|
|
89
|
+
사용합니다. HTTP 바인딩에서 온 규칙은 `source`를 붙이며, standalone validation이나
|
|
90
|
+
Standard Schema 이슈에서는 값이 없을 수 있습니다.
|
|
66
91
|
|
|
67
|
-
|
|
92
|
+
### Mapped DTO 헬퍼
|
|
68
93
|
|
|
69
|
-
```
|
|
94
|
+
```ts
|
|
70
95
|
import { IsString, IsEmail, PickType, PartialType } from '@fluojs/validation';
|
|
71
96
|
|
|
72
97
|
class UserDto {
|
|
73
|
-
@IsString() name
|
|
74
|
-
@IsEmail() email
|
|
98
|
+
@IsString() name = '';
|
|
99
|
+
@IsEmail() email = '';
|
|
75
100
|
}
|
|
76
101
|
|
|
77
|
-
// 'email' 필드만 포함
|
|
78
102
|
class EmailOnlyDto extends PickType(UserDto, ['email']) {}
|
|
79
|
-
|
|
80
|
-
// 모든 필드를 선택 사항(optional)으로 변경
|
|
81
103
|
class UpdateUserDto extends PartialType(UserDto) {}
|
|
82
104
|
```
|
|
83
105
|
|
|
84
|
-
### Standard Schema 지원
|
|
106
|
+
### Standard Schema 지원
|
|
85
107
|
|
|
86
|
-
|
|
87
|
-
유효하지 않은 입력은 명시적인 `issues`로 보고되어야 하며, 이슈가 없는 검증 결과는 성공으로 처리합니다.
|
|
108
|
+
Standard Schema adapter는 유효하지 않은 입력을 명시적인 issue로 보고해야 합니다. issue가 없는 검증 결과는 성공으로 처리합니다.
|
|
88
109
|
|
|
89
|
-
```
|
|
110
|
+
```ts
|
|
90
111
|
import { ValidateClass } from '@fluojs/validation';
|
|
91
112
|
import { z } from 'zod';
|
|
92
113
|
|
|
93
|
-
const UserSchema = z.object({
|
|
94
|
-
age: z.number().min(18),
|
|
95
|
-
});
|
|
114
|
+
const UserSchema = z.object({ age: z.number().min(18) });
|
|
96
115
|
|
|
97
116
|
@ValidateClass(UserSchema)
|
|
98
117
|
class RestrictedUserDto {
|
|
99
|
-
age
|
|
118
|
+
age = 0;
|
|
100
119
|
}
|
|
101
120
|
```
|
|
102
121
|
|
|
103
|
-
|
|
122
|
+
`ValidateClass(...)`는 custom class-level validator도 받을 수 있습니다. `Validate(...)`는 built-in decorator만으로 부족할 때 custom field-level validator를 붙이고, `ValidateIf(...)`는 predicate가 false를 반환하면 dependent validator를 short-circuit합니다.
|
|
104
123
|
|
|
105
|
-
|
|
124
|
+
### 중첩 검증
|
|
106
125
|
|
|
107
|
-
|
|
108
|
-
import { IsString, ValidateNested } from '@fluojs/validation';
|
|
126
|
+
`@ValidateNested(...)`는 객체 필드, 배열, `Set`, `Map`을 지원합니다. 중첩 DTO path는 validation issue에서 dot/index 표기법을 사용하며, cycle은 안전하게 감지되고 shared reference는 허용됩니다.
|
|
109
127
|
|
|
110
|
-
|
|
111
|
-
@IsString() bio: string = '';
|
|
112
|
-
}
|
|
128
|
+
### 암묵적 scalar coercion 없음
|
|
113
129
|
|
|
114
|
-
|
|
115
|
-
@IsString() name: string = '';
|
|
116
|
-
|
|
117
|
-
@ValidateNested(() => ProfileDto)
|
|
118
|
-
profile?: ProfileDto;
|
|
119
|
-
}
|
|
120
|
-
```
|
|
130
|
+
`materialize()`는 의도적으로 엄격합니다. Transport가 `'42'`를 넘기고 DTO가 `number`를 기대한다면, transport나 binding layer가 먼저 변환해야 합니다.
|
|
121
131
|
|
|
122
132
|
## 공개 API
|
|
123
133
|
|
|
124
|
-
- **검증 엔진**: `DefaultValidator`, `DtoValidationError`, `ValidationIssue`
|
|
125
|
-
- **핵심 데코레이터**: `IsString`, `IsNumber`, `IsBoolean`, `
|
|
134
|
+
- **검증 엔진**: `DefaultValidator`, `DtoValidationError`, `ValidationIssue`, `Validator`
|
|
135
|
+
- **핵심 데코레이터**: `IsString`, `IsNumber`, `IsBoolean`, `IsDate`, `IsArray`, `IsObject`, `IsEnum`, `IsInt`, `IsDefined`, `IsOptional`, `ValidateNested`, `ValidateIf`, `Validate`, `ValidateClass`
|
|
136
|
+
- **존재 및 비교 데코레이터**: `IsEmpty`, `IsNotEmpty`, `Equals`, `NotEquals`, `IsIn`, `IsNotIn`
|
|
137
|
+
- **문자열 및 네트워크 데코레이터**: `IsEmail`, `IsUrl`, `IsUUID`, `IsIP`, `IsAlpha`, `IsAlphanumeric`, `IsAscii`, `IsBase64`, `IsBooleanString`, `IsDataURI`, `IsDateString`, `IsDecimal`, `IsFQDN`, `IsHexColor`, `IsHexadecimal`, `IsJSON`, `IsJWT`, `IsLocale`, `IsLowercase`, `IsMagnetURI`, `IsMimeType`, `IsMongoId`, `IsNumberString`, `IsPort`, `IsRFC3339`, `IsSemVer`, `IsUppercase`, `IsISO8601`, `Matches`, `Length`, `MinLength`, `MaxLength`, `Contains`, `NotContains`
|
|
138
|
+
- **숫자, 날짜, 지리, locale 데코레이터**: `Min`, `Max`, `IsPositive`, `IsNegative`, `IsDivisibleBy`, `MinDate`, `MaxDate`, `IsLatitude`, `IsLongitude`, `IsLatLong`, `IsISBN`, `IsISSN`, `IsMobilePhone`, `IsPostalCode`, `IsRgbColor`, `IsCurrency`
|
|
139
|
+
- **배열 데코레이터**: `ArrayContains`, `ArrayNotContains`, `ArrayNotEmpty`, `ArrayMinSize`, `ArrayMaxSize`, `ArrayUnique`
|
|
126
140
|
- **Mapped DTO 헬퍼**: `PickType`, `OmitType`, `PartialType`, `IntersectionType`
|
|
141
|
+
- **Mapped DTO 서브패스**: `@fluojs/validation/mapped-types`
|
|
142
|
+
- **Standard Schema 계약**: `ValidateClass(...)` 스키마를 타입 지정하기 위한 `StandardSchemaV1Like`
|
|
127
143
|
- **검증 흐름**: 실체화 및 검증을 위한 `materialize()`, 단순 검증을 위한 `validate()`
|
|
128
144
|
|
|
129
145
|
## 관련 패키지
|
|
130
146
|
|
|
131
|
-
- `@fluojs/
|
|
132
|
-
- `@fluojs/
|
|
133
|
-
- `@fluojs/
|
|
147
|
+
- `@fluojs/http`: request data를 bind한 뒤 이 패키지로 검증합니다.
|
|
148
|
+
- `@fluojs/serialization`: response side에서 output DTO를 가공합니다.
|
|
149
|
+
- `@fluojs/core`: validation decorator가 사용하는 metadata primitive를 제공합니다.
|
|
134
150
|
|
|
135
151
|
## 예제 소스
|
|
136
152
|
|
|
137
|
-
- `packages/validation/src/validation.test.ts
|
|
138
|
-
- `
|
|
153
|
+
- `packages/validation/src/validation.test.ts`
|
|
154
|
+
- `packages/validation/src/mapped-types.test.ts`
|
|
155
|
+
- `examples/realworld-api/src/users/create-user.dto.ts`
|
|
156
|
+
- `examples/auth-jwt-passport/src/auth/login.dto.ts`
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<p><strong><kbd>English</kbd></strong> <a href="./README.ko.md"><kbd>한국어</kbd></a></p>
|
|
4
4
|
|
|
5
|
-
Input-side validation decorators, mapped DTO helpers, and the
|
|
5
|
+
Input-side validation decorators, mapped DTO helpers, and the validation engine for fluo.
|
|
6
6
|
|
|
7
7
|
## Table of Contents
|
|
8
8
|
|
|
@@ -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
|
|
|
@@ -94,15 +121,27 @@ class RestrictedUserDto {
|
|
|
94
121
|
}
|
|
95
122
|
```
|
|
96
123
|
|
|
124
|
+
`ValidateClass(...)` also accepts custom class-level validators. `Validate(...)` attaches custom field-level validators when built-in decorators are not enough, and `ValidateIf(...)` short-circuits dependent validators when its predicate returns false.
|
|
125
|
+
|
|
126
|
+
### Nested validation
|
|
127
|
+
|
|
128
|
+
`@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.
|
|
129
|
+
|
|
97
130
|
### No implicit scalar coercion
|
|
98
131
|
|
|
99
132
|
`materialize()` is intentionally strict. If a transport gives you `'42'` and your DTO expects `number`, the transport or binding layer must convert it first.
|
|
100
133
|
|
|
101
134
|
## Public API
|
|
102
135
|
|
|
103
|
-
- **Validator engine**: `DefaultValidator`, `DtoValidationError`, `ValidationIssue`
|
|
104
|
-
- **Core decorators**: `IsString`, `IsNumber`, `IsBoolean`, `
|
|
136
|
+
- **Validator engine**: `DefaultValidator`, `DtoValidationError`, `ValidationIssue`, `Validator`
|
|
137
|
+
- **Core decorators**: `IsString`, `IsNumber`, `IsBoolean`, `IsDate`, `IsArray`, `IsObject`, `IsEnum`, `IsInt`, `IsDefined`, `IsOptional`, `ValidateNested`, `ValidateIf`, `Validate`, `ValidateClass`
|
|
138
|
+
- **Presence and comparison decorators**: `IsEmpty`, `IsNotEmpty`, `Equals`, `NotEquals`, `IsIn`, `IsNotIn`
|
|
139
|
+
- **String and network decorators**: `IsEmail`, `IsUrl`, `IsUUID`, `IsIP`, `IsAlpha`, `IsAlphanumeric`, `IsAscii`, `IsBase64`, `IsBooleanString`, `IsDataURI`, `IsDateString`, `IsDecimal`, `IsFQDN`, `IsHexColor`, `IsHexadecimal`, `IsJSON`, `IsJWT`, `IsLocale`, `IsLowercase`, `IsMagnetURI`, `IsMimeType`, `IsMongoId`, `IsNumberString`, `IsPort`, `IsRFC3339`, `IsSemVer`, `IsUppercase`, `IsISO8601`, `Matches`, `Length`, `MinLength`, `MaxLength`, `Contains`, `NotContains`
|
|
140
|
+
- **Number, date, geo, and locale decorators**: `Min`, `Max`, `IsPositive`, `IsNegative`, `IsDivisibleBy`, `MinDate`, `MaxDate`, `IsLatitude`, `IsLongitude`, `IsLatLong`, `IsISBN`, `IsISSN`, `IsMobilePhone`, `IsPostalCode`, `IsRgbColor`, `IsCurrency`
|
|
141
|
+
- **Array decorators**: `ArrayContains`, `ArrayNotContains`, `ArrayNotEmpty`, `ArrayMinSize`, `ArrayMaxSize`, `ArrayUnique`
|
|
105
142
|
- **Mapped DTO helpers**: `PickType`, `OmitType`, `PartialType`, `IntersectionType`
|
|
143
|
+
- **Mapped DTO subpath**: `@fluojs/validation/mapped-types`
|
|
144
|
+
- **Standard Schema contract**: `StandardSchemaV1Like` for typing `ValidateClass(...)` schemas
|
|
106
145
|
- **Validation flow**: `materialize()` for hydration + validation, `validate()` for validation-only checks
|
|
107
146
|
|
|
108
147
|
## Related Packages
|
|
@@ -114,5 +153,6 @@ class RestrictedUserDto {
|
|
|
114
153
|
## Example Sources
|
|
115
154
|
|
|
116
155
|
- `packages/validation/src/validation.test.ts`
|
|
156
|
+
- `packages/validation/src/mapped-types.test.ts`
|
|
117
157
|
- `examples/realworld-api/src/users/create-user.dto.ts`
|
|
118
158
|
- `examples/auth-jwt-passport/src/auth/login.dto.ts`
|
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.
|