@fluojs/validation 1.0.0 → 1.0.1
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 +5 -0
- package/README.md +5 -0
- package/dist/mapped-types.d.ts.map +1 -1
- package/dist/mapped-types.js +6 -7
- package/package.json +2 -2
package/README.ko.md
CHANGED
|
@@ -113,6 +113,11 @@ class EmailOnlyDto extends PickType(UserDto, ['email']) {}
|
|
|
113
113
|
class UpdateUserDto extends PartialType(UserDto) {}
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
+
Mapped DTO helper는 위와 같은 문서화된 subclassing 패턴에서도 field-level
|
|
117
|
+
validation 및 binding metadata를 보존합니다. `PickType`, `OmitType`,
|
|
118
|
+
`PartialType`은 생략되었거나 optional이 된 필드에 의존할 수 있는 base
|
|
119
|
+
class-level validator를 derived DTO로 전달하지 않습니다.
|
|
120
|
+
|
|
116
121
|
### Standard Schema 지원
|
|
117
122
|
|
|
118
123
|
Standard Schema adapter는 유효하지 않은 입력을 명시적인 issue로 보고해야 합니다. issue가 없는 검증 결과는 성공으로 처리합니다.
|
package/README.md
CHANGED
|
@@ -117,6 +117,11 @@ class EmailOnlyDto extends PickType(UserDto, ['email']) {}
|
|
|
117
117
|
class UpdateUserDto extends PartialType(UserDto) {}
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
+
Mapped DTO helpers preserve field-level validation and binding metadata through
|
|
121
|
+
the documented subclassing pattern shown above. `PickType`, `OmitType`, and
|
|
122
|
+
`PartialType` do not carry base class-level validators onto derived DTOs because
|
|
123
|
+
those validators can depend on fields that were omitted or made optional.
|
|
124
|
+
|
|
120
125
|
### Standard Schema support
|
|
121
126
|
|
|
122
127
|
Standard Schema adapters are expected to report invalid input through explicit issues. Validation results without issues are treated as successful.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapped-types.d.ts","sourceRoot":"","sources":["../src/mapped-types.ts"],"names":[],"mappings":"AAAA,O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CAAC,YAAY,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAE9H;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,SAAS,SAAS,CAAC,cAAc,EAAE,cAAc,EAAE,GAAG,cAAc,EAAE,CAAC,EAC/G,GAAG,QAAQ,EAAE,SAAS,GACrB,cAAc,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC,CAkBjD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,CAAC,KAAK,SAAS,cAAc,EAAE,OAAO,EAAE,KAAK,GAAG,cAAc,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CA6BtH"}
|
package/dist/mapped-types.js
CHANGED
|
@@ -24,7 +24,7 @@ function collectDtoKeys(dto) {
|
|
|
24
24
|
}
|
|
25
25
|
return [...keys];
|
|
26
26
|
}
|
|
27
|
-
function copyDtoMetadata(source, target, include) {
|
|
27
|
+
function copyDtoMetadata(source, target, include, copyClassRules = false) {
|
|
28
28
|
for (const entry of getDtoBindingSchema(source)) {
|
|
29
29
|
if (!include(entry.propertyKey)) {
|
|
30
30
|
continue;
|
|
@@ -39,8 +39,10 @@ function copyDtoMetadata(source, target, include) {
|
|
|
39
39
|
appendDtoFieldValidationRule(target.prototype, entry.propertyKey, rule);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
if (copyClassRules) {
|
|
43
|
+
for (const rule of getClassValidationRules(source)) {
|
|
44
|
+
appendClassValidationRule(target, rule);
|
|
45
|
+
}
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
|
|
@@ -150,7 +152,7 @@ export function IntersectionType(...baseDtos) {
|
|
|
150
152
|
}
|
|
151
153
|
});
|
|
152
154
|
for (const BaseDto of baseDtos) {
|
|
153
|
-
copyDtoMetadata(BaseDto, IntersectionDto, () => true);
|
|
155
|
+
copyDtoMetadata(BaseDto, IntersectionDto, () => true, true);
|
|
154
156
|
}
|
|
155
157
|
return IntersectionDto;
|
|
156
158
|
}
|
|
@@ -200,8 +202,5 @@ export function PartialType(BaseDto) {
|
|
|
200
202
|
});
|
|
201
203
|
}
|
|
202
204
|
}
|
|
203
|
-
for (const rule of getClassValidationRules(BaseDto)) {
|
|
204
|
-
appendClassValidationRule(PartialDto, rule);
|
|
205
|
-
}
|
|
206
205
|
return PartialDto;
|
|
207
206
|
}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"decorators",
|
|
10
10
|
"schema"
|
|
11
11
|
],
|
|
12
|
-
"version": "1.0.
|
|
12
|
+
"version": "1.0.1",
|
|
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.
|
|
45
|
+
"@fluojs/core": "^1.0.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/validator": "^13.15.10",
|