@fluojs/validation 1.0.4 → 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 -132
- 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
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DtoFieldValidationRule, ValidationDecoratorOptions } from '@fluojs/core/request-pipeline';
|
|
2
|
+
import { type FieldDecoratorFn } from './decorator-metadata.js';
|
|
3
|
+
type ValidatorJsRuleName = Extract<DtoFieldValidationRule, {
|
|
4
|
+
kind: 'validatorjs';
|
|
5
|
+
}>['validator'];
|
|
6
|
+
export declare function createValidationDecorator(ruleFactory: () => DtoFieldValidationRule): FieldDecoratorFn;
|
|
7
|
+
export declare function createValidationOptionsWithConfigDecorator<T>(ruleFactory: (value: T, options: ValidationDecoratorOptions | undefined) => DtoFieldValidationRule): (value: T, options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
8
|
+
export declare function createFlagValidationDecorator(ruleFactory: (options: ValidationDecoratorOptions | undefined) => DtoFieldValidationRule): (options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
9
|
+
export declare function createArrayValidationDecorator<T>(ruleFactory: (values: readonly T[], options: ValidationDecoratorOptions | undefined) => DtoFieldValidationRule): (values: readonly T[], options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
10
|
+
export declare function createValidatorJsDecorator(validator: ValidatorJsRuleName): (args?: readonly unknown[], options?: ValidationDecoratorOptions) => FieldDecoratorFn;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=decorator-factories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorator-factories.d.ts","sourceRoot":"","sources":["../../src/internal/decorator-factories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAExG,OAAO,EAAmC,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEjG,KAAK,mBAAmB,GAAG,OAAO,CAAC,sBAAsB,EAAE;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC,CAAC,WAAW,CAAC,CAAC;AAEjG,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,sBAAsB,GAAG,gBAAgB,CAMrG;AAED,wBAAgB,0CAA0C,CAAC,CAAC,EAC1D,WAAW,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,0BAA0B,GAAG,SAAS,KAAK,sBAAsB,IAE1F,OAAO,CAAC,EAAE,UAAU,0BAA0B,KAAG,gBAAgB,CAG1E;AAED,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,CAAC,OAAO,EAAE,0BAA0B,GAAG,SAAS,KAAK,sBAAsB,IAEhF,UAAU,0BAA0B,KAAG,gBAAgB,CAGhE;AAED,wBAAgB,8BAA8B,CAAC,CAAC,EAC9C,WAAW,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,EAAE,OAAO,EAAE,0BAA0B,GAAG,SAAS,KAAK,sBAAsB,IAEtG,QAAQ,SAAS,CAAC,EAAE,EAAE,UAAU,0BAA0B,KAAG,gBAAgB,CAGtF;AAED,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,mBAAmB,IAC/D,OAAO,SAAS,OAAO,EAAE,EAAE,UAAU,0BAA0B,KAAG,gBAAgB,CAQ3F"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { appendStandardDtoValidationRule } from './decorator-metadata.js';
|
|
2
|
+
export function createValidationDecorator(ruleFactory) {
|
|
3
|
+
const decorator = (_value, context) => {
|
|
4
|
+
appendStandardDtoValidationRule(context.metadata, context.name, ruleFactory());
|
|
5
|
+
};
|
|
6
|
+
return decorator;
|
|
7
|
+
}
|
|
8
|
+
export function createValidationOptionsWithConfigDecorator(ruleFactory) {
|
|
9
|
+
return (value, options) => {
|
|
10
|
+
return createValidationDecorator(() => ruleFactory(value, options));
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function createFlagValidationDecorator(ruleFactory) {
|
|
14
|
+
return options => {
|
|
15
|
+
return createValidationDecorator(() => ruleFactory(options));
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function createArrayValidationDecorator(ruleFactory) {
|
|
19
|
+
return (values, options) => {
|
|
20
|
+
return createValidationDecorator(() => ruleFactory(values, options));
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function createValidatorJsDecorator(validator) {
|
|
24
|
+
return (args, options) => {
|
|
25
|
+
return createValidationDecorator(() => ({
|
|
26
|
+
args,
|
|
27
|
+
kind: 'validatorjs',
|
|
28
|
+
validator,
|
|
29
|
+
...options
|
|
30
|
+
}));
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { MetadataPropertyKey } from '@fluojs/core';
|
|
2
|
+
import type { ClassValidationRule, DtoFieldValidationRule } from '@fluojs/core/request-pipeline';
|
|
3
|
+
export type ClassDecoratorFn = (value: Function, context: ClassDecoratorContext) => void;
|
|
4
|
+
export type FieldDecoratorFn = <This, Value>(value: undefined, context: ClassFieldDecoratorContext<This, Value>) => void;
|
|
5
|
+
export declare function appendStandardDtoValidationRule(metadata: unknown, propertyKey: MetadataPropertyKey, rule: DtoFieldValidationRule): void;
|
|
6
|
+
export declare function appendStandardClassValidationRule(metadata: unknown, rule: ClassValidationRule): void;
|
|
7
|
+
//# sourceMappingURL=decorator-metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorator-metadata.d.ts","sourceRoot":"","sources":["../../src/internal/decorator-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEjG,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,qBAAqB,KAAK,IAAI,CAAC;AACzF,MAAM,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,0BAA0B,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,IAAI,CAAC;AA8CzH,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,OAAO,EACjB,WAAW,EAAE,mBAAmB,EAChC,IAAI,EAAE,sBAAsB,GAC3B,IAAI,CAGN;AAED,wBAAgB,iCAAiC,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAEpG"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const standardDtoValidationMetadataKey = Symbol.for('fluo.standard.dto-validation');
|
|
2
|
+
const standardClassValidationMetadataKey = Symbol.for('fluo.standard.class-validation');
|
|
3
|
+
function getStandardMetadataBag(metadata) {
|
|
4
|
+
if (metadata === null || metadata === undefined) {
|
|
5
|
+
throw new Error('Decorator metadata is not available. Ensure your environment supports TC39 decorator metadata (Stage 3).');
|
|
6
|
+
}
|
|
7
|
+
return metadata;
|
|
8
|
+
}
|
|
9
|
+
function getStandardDtoValidationMap(metadata) {
|
|
10
|
+
const bag = getStandardMetadataBag(metadata);
|
|
11
|
+
const current = bag[standardDtoValidationMetadataKey];
|
|
12
|
+
if (current && Object.hasOwn(bag, standardDtoValidationMetadataKey)) {
|
|
13
|
+
return current;
|
|
14
|
+
}
|
|
15
|
+
const created = new Map();
|
|
16
|
+
for (const [propertyKey, rules] of current ?? []) {
|
|
17
|
+
created.set(propertyKey, [...rules]);
|
|
18
|
+
}
|
|
19
|
+
bag[standardDtoValidationMetadataKey] = created;
|
|
20
|
+
return created;
|
|
21
|
+
}
|
|
22
|
+
function getStandardClassValidationList(metadata) {
|
|
23
|
+
const bag = getStandardMetadataBag(metadata);
|
|
24
|
+
const current = bag[standardClassValidationMetadataKey];
|
|
25
|
+
if (current && Object.hasOwn(bag, standardClassValidationMetadataKey)) {
|
|
26
|
+
return current;
|
|
27
|
+
}
|
|
28
|
+
const created = [...(current ?? [])];
|
|
29
|
+
bag[standardClassValidationMetadataKey] = created;
|
|
30
|
+
return created;
|
|
31
|
+
}
|
|
32
|
+
export function appendStandardDtoValidationRule(metadata, propertyKey, rule) {
|
|
33
|
+
const map = getStandardDtoValidationMap(metadata);
|
|
34
|
+
map.set(propertyKey, [...(map.get(propertyKey) ?? []), rule]);
|
|
35
|
+
}
|
|
36
|
+
export function appendStandardClassValidationRule(metadata, rule) {
|
|
37
|
+
getStandardClassValidationList(metadata).push(rule);
|
|
38
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Constructor, MetadataPropertyKey } from '@fluojs/core';
|
|
2
|
+
import { type DtoFieldBindingMetadata, getClassValidationRules, getDtoValidationSchema } from '@fluojs/core/request-pipeline';
|
|
3
|
+
export declare function resolveNestedDto(dto: Constructor | (() => Constructor)): Constructor;
|
|
4
|
+
type DtoValidationSchema = ReturnType<typeof getDtoValidationSchema>;
|
|
5
|
+
export interface CachedDtoMetadata {
|
|
6
|
+
bindingMap: Map<MetadataPropertyKey, DtoFieldBindingMetadata>;
|
|
7
|
+
classValidationRules: ReturnType<typeof getClassValidationRules>;
|
|
8
|
+
dtoValidationSchema: DtoValidationSchema;
|
|
9
|
+
mergedPropertyKeys: Set<MetadataPropertyKey>;
|
|
10
|
+
nestedDtoTransforms: readonly {
|
|
11
|
+
propertyKey: MetadataPropertyKey;
|
|
12
|
+
target: Constructor;
|
|
13
|
+
}[];
|
|
14
|
+
}
|
|
15
|
+
export declare function getCachedDtoMetadata(target: Constructor): CachedDtoMetadata;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=dto-metadata-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dto-metadata-cache.d.ts","sourceRoot":"","sources":["../../src/internal/dto-metadata-cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EACL,KAAK,uBAAuB,EAE5B,uBAAuB,EAEvB,sBAAsB,EACvB,MAAM,+BAA+B,CAAC;AAMvC,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,WAAW,GAAG,CAAC,MAAM,WAAW,CAAC,GAAG,WAAW,CAMpF;AAED,KAAK,mBAAmB,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAErE,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,GAAG,CAAC,mBAAmB,EAAE,uBAAuB,CAAC,CAAC;IAC9D,oBAAoB,EAAE,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;IACjE,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,kBAAkB,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAC7C,mBAAmB,EAAE,SAAS;QAC5B,WAAW,EAAE,mBAAmB,CAAC;QACjC,MAAM,EAAE,WAAW,CAAC;KACrB,EAAE,CAAC;CACL;AA+BD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,GAAG,iBAAiB,CAyB3E"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { getClassValidationRules, getDtoBindingSchema, getDtoValidationSchema } from '@fluojs/core/request-pipeline';
|
|
2
|
+
function isClassConstructor(dto) {
|
|
3
|
+
return typeof dto === 'function' && Function.prototype.toString.call(dto).startsWith('class ');
|
|
4
|
+
}
|
|
5
|
+
export function resolveNestedDto(dto) {
|
|
6
|
+
if (isClassConstructor(dto)) {
|
|
7
|
+
return dto;
|
|
8
|
+
}
|
|
9
|
+
return dto();
|
|
10
|
+
}
|
|
11
|
+
const dtoMetadataCache = new WeakMap();
|
|
12
|
+
function getDtoBindingMap(target) {
|
|
13
|
+
return new Map(getDtoBindingSchema(target).map(entry => [entry.propertyKey, entry.metadata]));
|
|
14
|
+
}
|
|
15
|
+
function collectNestedDtoTransforms(dtoValidationSchema) {
|
|
16
|
+
const nestedEntries = [];
|
|
17
|
+
for (const entry of dtoValidationSchema) {
|
|
18
|
+
const nestedRule = entry.rules.find(rule => rule.kind === 'nested');
|
|
19
|
+
if (!nestedRule) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
nestedEntries.push({
|
|
23
|
+
propertyKey: entry.propertyKey,
|
|
24
|
+
target: resolveNestedDto(nestedRule.dto)
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return nestedEntries;
|
|
28
|
+
}
|
|
29
|
+
export function getCachedDtoMetadata(target) {
|
|
30
|
+
const cached = dtoMetadataCache.get(target);
|
|
31
|
+
if (cached) {
|
|
32
|
+
return cached;
|
|
33
|
+
}
|
|
34
|
+
const bindingMap = getDtoBindingMap(target);
|
|
35
|
+
const dtoValidationSchema = getDtoValidationSchema(target);
|
|
36
|
+
const classValidationRules = getClassValidationRules(target);
|
|
37
|
+
const mergedPropertyKeys = new Set([...bindingMap.keys(), ...dtoValidationSchema.map(entry => entry.propertyKey)]);
|
|
38
|
+
const nestedDtoTransforms = collectNestedDtoTransforms(dtoValidationSchema);
|
|
39
|
+
const next = {
|
|
40
|
+
bindingMap,
|
|
41
|
+
classValidationRules,
|
|
42
|
+
dtoValidationSchema,
|
|
43
|
+
mergedPropertyKeys,
|
|
44
|
+
nestedDtoTransforms
|
|
45
|
+
};
|
|
46
|
+
dtoMetadataCache.set(target, next);
|
|
47
|
+
return next;
|
|
48
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function getIterableValues(value: unknown): unknown[] | undefined;
|
|
2
|
+
export declare function isPlainObject(value: unknown): value is Record<PropertyKey, unknown>;
|
|
3
|
+
export declare function assignSafeOwnEnumerableProperties(target: Record<PropertyKey, unknown>, source: Record<PropertyKey, unknown>): void;
|
|
4
|
+
//# sourceMappingURL=object-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-utils.d.ts","sourceRoot":"","sources":["../../src/internal/object-utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,EAAE,GAAG,SAAS,CAKvE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAOnF;AAID,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,EACpC,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,GACnC,IAAI,CAYN"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function getIterableValues(value) {
|
|
2
|
+
if (Array.isArray(value)) return value;
|
|
3
|
+
if (value instanceof Set) return Array.from(value.values());
|
|
4
|
+
if (value instanceof Map) return Array.from(value.values());
|
|
5
|
+
return undefined;
|
|
6
|
+
}
|
|
7
|
+
export function isPlainObject(value) {
|
|
8
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const prototype = Object.getPrototypeOf(value);
|
|
12
|
+
return prototype === Object.prototype || prototype === null;
|
|
13
|
+
}
|
|
14
|
+
const dangerousKeys = new Set(['__proto__', 'constructor', 'prototype']);
|
|
15
|
+
export function assignSafeOwnEnumerableProperties(target, source) {
|
|
16
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
17
|
+
if (typeof key === 'string' && dangerousKeys.has(key)) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
target[key] = source[key];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DtoFieldValidationRule } from '@fluojs/core/request-pipeline';
|
|
2
|
+
type RuleKind = DtoFieldValidationRule['kind'];
|
|
3
|
+
export type NonCustomRule = Exclude<DtoFieldValidationRule, {
|
|
4
|
+
kind: 'custom' | 'nested';
|
|
5
|
+
}>;
|
|
6
|
+
type RuleHandler<K extends RuleKind> = {
|
|
7
|
+
defaultCode: string;
|
|
8
|
+
describe: (field: string, rule: Extract<DtoFieldValidationRule, {
|
|
9
|
+
kind: K;
|
|
10
|
+
}>) => string;
|
|
11
|
+
validate: (rule: Extract<DtoFieldValidationRule, {
|
|
12
|
+
kind: K;
|
|
13
|
+
}>, value: unknown) => boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare function getRuleHandler<K extends RuleKind>(rule: Extract<DtoFieldValidationRule, {
|
|
16
|
+
kind: K;
|
|
17
|
+
}>): RuleHandler<K>;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=rule-handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-handlers.d.ts","sourceRoot":"","sources":["../../src/internal/rule-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAK5E,KAAK,QAAQ,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC;AAE/C,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,sBAAsB,EAAE;IAAE,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAA;CAAE,CAAC,CAAC;AAE3F,KAAK,WAAW,CAAC,CAAC,SAAS,QAAQ,IAAI;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,sBAAsB,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,KAAK,MAAM,CAAC;IACxF,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,sBAAsB,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;CAC3F,CAAC;AAgNF,wBAAgB,cAAc,CAAC,CAAC,SAAS,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,sBAAsB,EAAE;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAErH"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { isPlainObject } from './object-utils.js';
|
|
2
|
+
import { runValidatorJs } from './validator-js-adapter.js';
|
|
3
|
+
function isEmptyValue(value) {
|
|
4
|
+
return value === '' || value === null || value === undefined;
|
|
5
|
+
}
|
|
6
|
+
const ruleHandlers = {
|
|
7
|
+
validateIf: {
|
|
8
|
+
defaultCode: 'VALIDATE_IF',
|
|
9
|
+
describe: field => `${field} is conditionally invalid.`,
|
|
10
|
+
validate: () => true
|
|
11
|
+
},
|
|
12
|
+
defined: {
|
|
13
|
+
defaultCode: 'REQUIRED',
|
|
14
|
+
describe: field => `${field} is required.`,
|
|
15
|
+
validate: (_rule, value) => value !== undefined && value !== null
|
|
16
|
+
},
|
|
17
|
+
optional: {
|
|
18
|
+
defaultCode: 'OPTIONAL',
|
|
19
|
+
describe: field => `${field} is optional.`,
|
|
20
|
+
validate: () => true
|
|
21
|
+
},
|
|
22
|
+
equals: {
|
|
23
|
+
defaultCode: 'EQUALS',
|
|
24
|
+
describe: (field, rule) => `${field} must equal ${String(rule.value)}.`,
|
|
25
|
+
validate: (rule, value) => value === rule.value
|
|
26
|
+
},
|
|
27
|
+
notEquals: {
|
|
28
|
+
defaultCode: 'NOT_EQUALS',
|
|
29
|
+
describe: (field, rule) => `${field} must not equal ${String(rule.value)}.`,
|
|
30
|
+
validate: (rule, value) => value !== rule.value
|
|
31
|
+
},
|
|
32
|
+
empty: {
|
|
33
|
+
defaultCode: 'EMPTY',
|
|
34
|
+
describe: field => `${field} must be empty.`,
|
|
35
|
+
validate: (_rule, value) => isEmptyValue(value)
|
|
36
|
+
},
|
|
37
|
+
notEmpty: {
|
|
38
|
+
defaultCode: 'NOT_EMPTY',
|
|
39
|
+
describe: field => `${field} should not be empty.`,
|
|
40
|
+
validate: (_rule, value) => !isEmptyValue(value)
|
|
41
|
+
},
|
|
42
|
+
in: {
|
|
43
|
+
defaultCode: 'IN',
|
|
44
|
+
describe: field => `${field} must be one of the allowed values.`,
|
|
45
|
+
validate: (rule, value) => rule.values.includes(value)
|
|
46
|
+
},
|
|
47
|
+
notIn: {
|
|
48
|
+
defaultCode: 'NOT_IN',
|
|
49
|
+
describe: field => `${field} contains a forbidden value.`,
|
|
50
|
+
validate: (rule, value) => !rule.values.includes(value)
|
|
51
|
+
},
|
|
52
|
+
string: {
|
|
53
|
+
defaultCode: 'INVALID_STRING',
|
|
54
|
+
describe: field => `${field} must be a string.`,
|
|
55
|
+
validate: (_rule, value) => typeof value === 'string'
|
|
56
|
+
},
|
|
57
|
+
number: {
|
|
58
|
+
defaultCode: 'INVALID_NUMBER',
|
|
59
|
+
describe: field => `${field} must be a number.`,
|
|
60
|
+
validate: (rule, value) => typeof value === 'number' && (rule.allowNaN || !Number.isNaN(value))
|
|
61
|
+
},
|
|
62
|
+
boolean: {
|
|
63
|
+
defaultCode: 'INVALID_BOOLEAN',
|
|
64
|
+
describe: field => `${field} must be a boolean.`,
|
|
65
|
+
validate: (_rule, value) => typeof value === 'boolean'
|
|
66
|
+
},
|
|
67
|
+
date: {
|
|
68
|
+
defaultCode: 'INVALID_DATE',
|
|
69
|
+
describe: field => `${field} must be a Date instance.`,
|
|
70
|
+
validate: (_rule, value) => value instanceof Date && !Number.isNaN(value.getTime())
|
|
71
|
+
},
|
|
72
|
+
array: {
|
|
73
|
+
defaultCode: 'INVALID_ARRAY',
|
|
74
|
+
describe: field => `${field} must be an array.`,
|
|
75
|
+
validate: (_rule, value) => Array.isArray(value)
|
|
76
|
+
},
|
|
77
|
+
object: {
|
|
78
|
+
defaultCode: 'INVALID_OBJECT',
|
|
79
|
+
describe: field => `${field} must be an object.`,
|
|
80
|
+
validate: (_rule, value) => isPlainObject(value)
|
|
81
|
+
},
|
|
82
|
+
enum: {
|
|
83
|
+
defaultCode: 'INVALID_ENUM',
|
|
84
|
+
describe: field => `${field} must be a supported enum value.`,
|
|
85
|
+
validate: (rule, value) => rule.values.includes(value)
|
|
86
|
+
},
|
|
87
|
+
int: {
|
|
88
|
+
defaultCode: 'INVALID_INT',
|
|
89
|
+
describe: field => `${field} must be an integer.`,
|
|
90
|
+
validate: (_rule, value) => typeof value === 'number' && Number.isInteger(value)
|
|
91
|
+
},
|
|
92
|
+
divisibleBy: {
|
|
93
|
+
defaultCode: 'DIVISIBLE_BY',
|
|
94
|
+
describe: (field, rule) => `${field} must be divisible by ${String(rule.value)}.`,
|
|
95
|
+
validate: (rule, value) => typeof value === 'number' && !Number.isNaN(value) && value % rule.value === 0
|
|
96
|
+
},
|
|
97
|
+
positive: {
|
|
98
|
+
defaultCode: 'POSITIVE',
|
|
99
|
+
describe: field => `${field} must be positive.`,
|
|
100
|
+
validate: (_rule, value) => typeof value === 'number' && value > 0
|
|
101
|
+
},
|
|
102
|
+
negative: {
|
|
103
|
+
defaultCode: 'NEGATIVE',
|
|
104
|
+
describe: field => `${field} must be negative.`,
|
|
105
|
+
validate: (_rule, value) => typeof value === 'number' && value < 0
|
|
106
|
+
},
|
|
107
|
+
min: {
|
|
108
|
+
defaultCode: 'MIN',
|
|
109
|
+
describe: (field, rule) => `${field} must be greater than or equal to ${String(rule.value)}.`,
|
|
110
|
+
validate: (rule, value) => typeof value === 'number' && !Number.isNaN(value) && value >= rule.value
|
|
111
|
+
},
|
|
112
|
+
max: {
|
|
113
|
+
defaultCode: 'MAX',
|
|
114
|
+
describe: (field, rule) => `${field} must be less than or equal to ${String(rule.value)}.`,
|
|
115
|
+
validate: (rule, value) => typeof value === 'number' && !Number.isNaN(value) && value <= rule.value
|
|
116
|
+
},
|
|
117
|
+
minDate: {
|
|
118
|
+
defaultCode: 'MIN_DATE',
|
|
119
|
+
describe: (field, rule) => `${field} must be on or after ${rule.value.toISOString()}.`,
|
|
120
|
+
validate: (rule, value) => value instanceof Date && !Number.isNaN(value.getTime()) && value.getTime() >= rule.value.getTime()
|
|
121
|
+
},
|
|
122
|
+
maxDate: {
|
|
123
|
+
defaultCode: 'MAX_DATE',
|
|
124
|
+
describe: (field, rule) => `${field} must be on or before ${rule.value.toISOString()}.`,
|
|
125
|
+
validate: (rule, value) => value instanceof Date && !Number.isNaN(value.getTime()) && value.getTime() <= rule.value.getTime()
|
|
126
|
+
},
|
|
127
|
+
contains: {
|
|
128
|
+
defaultCode: 'CONTAINS',
|
|
129
|
+
describe: (field, rule) => `${field} must contain ${rule.value}.`,
|
|
130
|
+
validate: (rule, value) => typeof value === 'string' && value.includes(rule.value)
|
|
131
|
+
},
|
|
132
|
+
notContains: {
|
|
133
|
+
defaultCode: 'NOT_CONTAINS',
|
|
134
|
+
describe: (field, rule) => `${field} must not contain ${rule.value}.`,
|
|
135
|
+
validate: (rule, value) => typeof value === 'string' && !value.includes(rule.value)
|
|
136
|
+
},
|
|
137
|
+
length: {
|
|
138
|
+
defaultCode: 'LENGTH',
|
|
139
|
+
describe: field => `${field} must have a valid length.`,
|
|
140
|
+
validate: (rule, value) => typeof value === 'string' && value.length >= rule.min && (rule.max === undefined || value.length <= rule.max)
|
|
141
|
+
},
|
|
142
|
+
minLength: {
|
|
143
|
+
defaultCode: 'MIN_LENGTH',
|
|
144
|
+
describe: (field, rule) => `${field} must have length at least ${String(rule.value)}.`,
|
|
145
|
+
validate: (rule, value) => typeof value === 'string' && value.length >= rule.value
|
|
146
|
+
},
|
|
147
|
+
maxLength: {
|
|
148
|
+
defaultCode: 'MAX_LENGTH',
|
|
149
|
+
describe: (field, rule) => `${field} must have length at most ${String(rule.value)}.`,
|
|
150
|
+
validate: (rule, value) => typeof value === 'string' && value.length <= rule.value
|
|
151
|
+
},
|
|
152
|
+
nested: {
|
|
153
|
+
defaultCode: 'INVALID_NESTED',
|
|
154
|
+
describe: field => `${field} contains invalid nested data.`,
|
|
155
|
+
validate: () => true
|
|
156
|
+
},
|
|
157
|
+
validatorjs: {
|
|
158
|
+
defaultCode: 'INVALID_FIELD',
|
|
159
|
+
describe: field => `${field} is invalid.`,
|
|
160
|
+
validate: (rule, value) => runValidatorJs(rule, value)
|
|
161
|
+
},
|
|
162
|
+
arrayContains: {
|
|
163
|
+
defaultCode: 'ARRAY_CONTAINS',
|
|
164
|
+
describe: field => `${field} must contain the required values.`,
|
|
165
|
+
validate: (rule, value) => Array.isArray(value) && rule.values.every(expected => value.includes(expected))
|
|
166
|
+
},
|
|
167
|
+
arrayNotContains: {
|
|
168
|
+
defaultCode: 'ARRAY_NOT_CONTAINS',
|
|
169
|
+
describe: field => `${field} contains forbidden values.`,
|
|
170
|
+
validate: (rule, value) => Array.isArray(value) && rule.values.every(expected => !value.includes(expected))
|
|
171
|
+
},
|
|
172
|
+
arrayNotEmpty: {
|
|
173
|
+
defaultCode: 'ARRAY_NOT_EMPTY',
|
|
174
|
+
describe: field => `${field} must not be an empty array.`,
|
|
175
|
+
validate: (_rule, value) => Array.isArray(value) && value.length > 0
|
|
176
|
+
},
|
|
177
|
+
arrayMinSize: {
|
|
178
|
+
defaultCode: 'ARRAY_MIN_SIZE',
|
|
179
|
+
describe: (field, rule) => `${field} must contain at least ${String(rule.value)} items.`,
|
|
180
|
+
validate: (rule, value) => Array.isArray(value) && value.length >= rule.value
|
|
181
|
+
},
|
|
182
|
+
arrayMaxSize: {
|
|
183
|
+
defaultCode: 'ARRAY_MAX_SIZE',
|
|
184
|
+
describe: (field, rule) => `${field} must contain at most ${String(rule.value)} items.`,
|
|
185
|
+
validate: (rule, value) => Array.isArray(value) && value.length <= rule.value
|
|
186
|
+
},
|
|
187
|
+
arrayUnique: {
|
|
188
|
+
defaultCode: 'ARRAY_UNIQUE',
|
|
189
|
+
describe: field => `${field} must contain unique values.`,
|
|
190
|
+
validate: (rule, value) => {
|
|
191
|
+
if (!Array.isArray(value)) return false;
|
|
192
|
+
const seen = new Set();
|
|
193
|
+
for (const entry of value) {
|
|
194
|
+
const key = rule.selector ? rule.selector(entry) : entry;
|
|
195
|
+
if (seen.has(key)) return false;
|
|
196
|
+
seen.add(key);
|
|
197
|
+
}
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
custom: {
|
|
202
|
+
defaultCode: 'INVALID_FIELD',
|
|
203
|
+
describe: field => `${field} is invalid.`,
|
|
204
|
+
validate: () => true
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
export function getRuleHandler(rule) {
|
|
208
|
+
return ruleHandlers[rule.kind];
|
|
209
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator-js-adapter.d.ts","sourceRoot":"","sources":["../../src/internal/validator-js-adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAE5E,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,sBAAsB,EAAE;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAoDtH"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import validator from 'validator';
|
|
2
|
+
export function runValidatorJs(rule, value) {
|
|
3
|
+
if (rule.validator === 'latitude') {
|
|
4
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= -90 && value <= 90;
|
|
5
|
+
}
|
|
6
|
+
if (rule.validator === 'longitude') {
|
|
7
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= -180 && value <= 180;
|
|
8
|
+
}
|
|
9
|
+
if (typeof value !== 'string') {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
switch (rule.validator) {
|
|
13
|
+
case 'alpha':
|
|
14
|
+
return validator.isAlpha(value);
|
|
15
|
+
case 'alphanumeric':
|
|
16
|
+
return validator.isAlphanumeric(value);
|
|
17
|
+
case 'ascii':
|
|
18
|
+
return validator.isAscii(value);
|
|
19
|
+
case 'base64':
|
|
20
|
+
return validator.isBase64(value);
|
|
21
|
+
case 'booleanString':
|
|
22
|
+
return validator.isBoolean(value);
|
|
23
|
+
case 'currency':
|
|
24
|
+
return validator.isCurrency(value, rule.args?.[0]);
|
|
25
|
+
case 'dataURI':
|
|
26
|
+
return validator.isDataURI(value);
|
|
27
|
+
case 'dateString':
|
|
28
|
+
return validator.isISO8601(value);
|
|
29
|
+
case 'decimal':
|
|
30
|
+
return validator.isDecimal(value);
|
|
31
|
+
case 'email':
|
|
32
|
+
return validator.isEmail(value, rule.args?.[0]);
|
|
33
|
+
case 'fqdn':
|
|
34
|
+
return validator.isFQDN(value, rule.args?.[0]);
|
|
35
|
+
case 'hexColor':
|
|
36
|
+
return validator.isHexColor(value);
|
|
37
|
+
case 'hexadecimal':
|
|
38
|
+
return validator.isHexadecimal(value);
|
|
39
|
+
case 'ip':
|
|
40
|
+
return validator.isIP(value, rule.args?.[0]);
|
|
41
|
+
case 'isbn':
|
|
42
|
+
return validator.isISBN(value, rule.args?.[0]);
|
|
43
|
+
case 'issn':
|
|
44
|
+
return validator.isISSN(value);
|
|
45
|
+
case 'json':
|
|
46
|
+
return validator.isJSON(value);
|
|
47
|
+
case 'jwt':
|
|
48
|
+
return validator.isJWT(value);
|
|
49
|
+
case 'locale':
|
|
50
|
+
return validator.isLocale(value);
|
|
51
|
+
case 'lowercase':
|
|
52
|
+
return validator.isLowercase(value);
|
|
53
|
+
case 'magnetURI':
|
|
54
|
+
return validator.isMagnetURI(value);
|
|
55
|
+
case 'matches':
|
|
56
|
+
return validator.matches(value, rule.args?.[0], rule.args?.[1]);
|
|
57
|
+
case 'mimeType':
|
|
58
|
+
return validator.isMimeType(value);
|
|
59
|
+
case 'mobilePhone':
|
|
60
|
+
return validator.isMobilePhone(value, rule.args?.[0]);
|
|
61
|
+
case 'mongoId':
|
|
62
|
+
return validator.isMongoId(value);
|
|
63
|
+
case 'numberString':
|
|
64
|
+
return validator.isNumeric(value);
|
|
65
|
+
case 'port':
|
|
66
|
+
return validator.isPort(value);
|
|
67
|
+
case 'postalCode':
|
|
68
|
+
return validator.isPostalCode(value, rule.args?.[0] ?? 'any');
|
|
69
|
+
case 'rgbColor':
|
|
70
|
+
return validator.isRgbColor(value, rule.args?.[0]);
|
|
71
|
+
case 'rfc3339':
|
|
72
|
+
return validator.isRFC3339(value);
|
|
73
|
+
case 'semVer':
|
|
74
|
+
return validator.isSemVer(value);
|
|
75
|
+
case 'uppercase':
|
|
76
|
+
return validator.isUppercase(value);
|
|
77
|
+
case 'url':
|
|
78
|
+
return validator.isURL(value, rule.args?.[0]);
|
|
79
|
+
case 'uuid':
|
|
80
|
+
return validator.isUUID(value, rule.args?.[0]);
|
|
81
|
+
case 'iso8601':
|
|
82
|
+
return validator.isISO8601(value);
|
|
83
|
+
case 'latLong':
|
|
84
|
+
return validator.isLatLong(value);
|
|
85
|
+
default:
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
}
|
package/dist/mapped-types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapped-types.d.ts","sourceRoot":"","sources":["../src/mapped-types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"mapped-types.d.ts","sourceRoot":"","sources":["../src/mapped-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,cAAc,CAAC;AAUrE,KAAK,cAAc,CAAC,CAAC,GAAG,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;AAoEjD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,SAAS,cAAc,EAAE,IAAI,SAAS,OAAO,CAAC,MAAM,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,EAC5G,OAAO,EAAE,KAAK,EACd,IAAI,EAAE,SAAS,IAAI,EAAE,GACpB,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC,CAcjD;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,SAAS,cAAc,EAAE,IAAI,SAAS,OAAO,CAAC,MAAM,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,EAC5G,OAAO,EAAE,KAAK,EACd,IAAI,EAAE,SAAS,IAAI,EAAE,GACpB,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC,CAcjD;AAED,KAAK,mBAAmB,CAAC,CAAC,IAAI,CAC5B,CAAC,SAAS,OAAO,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,KAAK,CAC/C,SAAS,CAAC,KAAK,EAAE,MAAM,OAAO,KAAK,IAAI,GAAG,OAAO,GAAG,KAAK,CAAC;AAE3D,KAAK,oBAAoB,CAAC,SAAS,SAAS,SAAS,cAAc,EAAE,IAAI,mBAAmB,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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { appendClassValidationRule, appendDtoFieldValidationRule, defineDtoFieldBindingMetadata, getClassValidationRules, getDtoBindingSchema, getDtoValidationSchema } from '@fluojs/core/
|
|
1
|
+
import { appendClassValidationRule, appendDtoFieldValidationRule, defineDtoFieldBindingMetadata, getClassValidationRules, getDtoBindingSchema, getDtoValidationSchema } from '@fluojs/core/request-pipeline';
|
|
2
2
|
function setClassName(target, name) {
|
|
3
3
|
Object.defineProperty(target, 'name', {
|
|
4
4
|
configurable: true,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
import type { CustomClassValidator } from '@fluojs/core/
|
|
2
|
+
import type { CustomClassValidator } from '@fluojs/core/request-pipeline';
|
|
3
3
|
/**
|
|
4
4
|
* Standard Schema v1-compatible validator accepted by `ValidateClass`.
|
|
5
5
|
*
|
|
@@ -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,
|
|
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,+BAA+B,CAAC;AAI1E;;;;;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/types.d.ts
CHANGED
|
@@ -16,7 +16,11 @@ export interface ValidationIssue {
|
|
|
16
16
|
* Validation engine contract used by HTTP binding and app-level validation flows.
|
|
17
17
|
*/
|
|
18
18
|
export interface Validator {
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Validates an existing root DTO or plain object.
|
|
21
|
+
* Plain nested values may be temporarily materialized for nested DTO rules
|
|
22
|
+
* without replacing the caller's properties.
|
|
23
|
+
*/
|
|
20
24
|
validate(value: unknown, target: Constructor): MaybePromise<void>;
|
|
21
25
|
/** Materializes and validates a value into a typed DTO instance. */
|
|
22
26
|
materialize<T>(value: unknown, target: Constructor<T>): MaybePromise<T>;
|
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,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,OAAO,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,OAAO,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAClE,oEAAoE;IACpE,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;CACzE"}
|
package/dist/validation.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EAEZ,MAAM,cAAc,CAAC;AAOtB,OAAO,KAAK,EAAmB,SAAS,EAAE,MAAM,YAAY,CAAC;AAga7D;;GAEG;AACH,qBAAa,gBAAiB,YAAW,SAAS;IAC1C,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ5D,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAYzE"}
|