@maroonedog/luq 0.1.0-alpha
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/LICENSE +9 -0
- package/README.md +879 -0
- package/dist/constants.d.ts +27 -0
- package/dist/core/async.experimental/async-context.d.ts +60 -0
- package/dist/core/builder/array-batch-optimizer.d.ts +66 -0
- package/dist/core/builder/context/field-context.d.ts +31 -0
- package/dist/core/builder/context/field-type-detector.d.ts +19 -0
- package/dist/core/builder/core/builder.d.ts +10 -0
- package/dist/core/builder/core/field-builder.d.ts +13 -0
- package/dist/core/builder/core/index.d.ts +17 -0
- package/dist/core/builder/index.d.ts +24 -0
- package/dist/core/builder/nested-array-processor.d.ts +52 -0
- package/dist/core/builder/plugins/composable-conditional-plugin.d.ts +32 -0
- package/dist/core/builder/plugins/composable-directly-plugin.d.ts +32 -0
- package/dist/core/builder/plugins/composable-plugin.d.ts +242 -0
- package/dist/core/builder/plugins/plugin-creator.d.ts +38 -0
- package/dist/core/builder/plugins/plugin-interfaces.d.ts +343 -0
- package/dist/core/builder/plugins/plugin-types.d.ts +441 -0
- package/dist/core/builder/raw-validator.d.ts +22 -0
- package/dist/core/builder/types/field-options.d.ts +46 -0
- package/dist/core/builder/types/types.d.ts +318 -0
- package/dist/core/builder/ultra-fast-validator.d.ts +30 -0
- package/dist/core/builder/validator-factory.d.ts +29 -0
- package/dist/core/global-config.d.ts +27 -0
- package/dist/core/index.d.ts +36 -0
- package/dist/core/optimization/array-batch-validator.d.ts +68 -0
- package/dist/core/optimization/core/field-utils.d.ts +103 -0
- package/dist/core/optimization/core/strategy-factory.d.ts +84 -0
- package/dist/core/optimization/core/validation-engine.d.ts +107 -0
- package/dist/core/optimization/execution-strategy-selector.d.ts +23 -0
- package/dist/core/optimization/unified-validator.d.ts +45 -0
- package/dist/core/plugin/__tests__/test-utils.d.ts +1 -0
- package/dist/core/plugin/arrayContains.d.ts +37 -0
- package/dist/core/plugin/arrayIncludes.d.ts +42 -0
- package/dist/core/plugin/arrayMaxLength.d.ts +43 -0
- package/dist/core/plugin/arrayMinLength.d.ts +43 -0
- package/dist/core/plugin/arrayUnique.d.ts +41 -0
- package/dist/core/plugin/booleanFalsy.d.ts +41 -0
- package/dist/core/plugin/booleanTruthy.d.ts +38 -0
- package/dist/core/plugin/compareField.d.ts +58 -0
- package/dist/core/plugin/conditionalSchema.d.ts +24 -0
- package/dist/core/plugin/custom.d.ts +60 -0
- package/dist/core/plugin/fromContext.d.ts +150 -0
- package/dist/core/plugin/index.d.ts +71 -0
- package/dist/core/plugin/jsonSchema/dsl-converter.d.ts +22 -0
- package/dist/core/plugin/jsonSchema/error-generation.d.ts +14 -0
- package/dist/core/plugin/jsonSchema/format-validators.d.ts +20 -0
- package/dist/core/plugin/jsonSchema/index.d.ts +11 -0
- package/dist/core/plugin/jsonSchema/plugin.d.ts +35 -0
- package/dist/core/plugin/jsonSchema/ref-resolver.d.ts +14 -0
- package/dist/core/plugin/jsonSchema/types.d.ts +69 -0
- package/dist/core/plugin/jsonSchema/validation-core.d.ts +29 -0
- package/dist/core/plugin/jsonSchemaFullFeature.d.ts +31 -0
- package/dist/core/plugin/literal.d.ts +40 -0
- package/dist/core/plugin/message-factories.d.ts +9 -0
- package/dist/core/plugin/nullable.d.ts +34 -0
- package/dist/core/plugin/numberFinite.d.ts +41 -0
- package/dist/core/plugin/numberInteger.d.ts +41 -0
- package/dist/core/plugin/numberMax.d.ts +49 -0
- package/dist/core/plugin/numberMin.d.ts +49 -0
- package/dist/core/plugin/numberMultipleOf.d.ts +42 -0
- package/dist/core/plugin/numberNegative.d.ts +41 -0
- package/dist/core/plugin/numberPositive.d.ts +41 -0
- package/dist/core/plugin/numberRange.d.ts +48 -0
- package/dist/core/plugin/object.d.ts +43 -0
- package/dist/core/plugin/objectAdditionalProperties.d.ts +51 -0
- package/dist/core/plugin/objectDependentRequired.d.ts +42 -0
- package/dist/core/plugin/objectDependentSchemas.d.ts +40 -0
- package/dist/core/plugin/objectMaxProperties.d.ts +42 -0
- package/dist/core/plugin/objectMinProperties.d.ts +42 -0
- package/dist/core/plugin/objectPatternProperties.d.ts +46 -0
- package/dist/core/plugin/objectPropertyNames.d.ts +36 -0
- package/dist/core/plugin/objectRecursively.d.ts +81 -0
- package/dist/core/plugin/oneOf.d.ts +44 -0
- package/dist/core/plugin/optional.d.ts +35 -0
- package/dist/core/plugin/optionalIf.d.ts +42 -0
- package/dist/core/plugin/orFail.d.ts +132 -0
- package/dist/core/plugin/readOnlyWriteOnly.d.ts +48 -0
- package/dist/core/plugin/required.d.ts +45 -0
- package/dist/core/plugin/requiredIf.d.ts +66 -0
- package/dist/core/plugin/shared-constants.d.ts +45 -0
- package/dist/core/plugin/shared.d.ts +3 -0
- package/dist/core/plugin/skip.d.ts +57 -0
- package/dist/core/plugin/stitch-typed.d.ts +15 -0
- package/dist/core/plugin/stitch.d.ts +1 -0
- package/dist/core/plugin/stitchSimple.d.ts +4 -0
- package/dist/core/plugin/stringAlphanumeric.d.ts +42 -0
- package/dist/core/plugin/stringBase64.d.ts +119 -0
- package/dist/core/plugin/stringContentEncoding.d.ts +43 -0
- package/dist/core/plugin/stringContentMediaType.d.ts +47 -0
- package/dist/core/plugin/stringDate.d.ts +48 -0
- package/dist/core/plugin/stringDatetime.d.ts +108 -0
- package/dist/core/plugin/stringDuration.d.ts +41 -0
- package/dist/core/plugin/stringEmail.d.ts +81 -0
- package/dist/core/plugin/stringEndsWith.d.ts +42 -0
- package/dist/core/plugin/stringExactLength.d.ts +46 -0
- package/dist/core/plugin/stringHostname.d.ts +104 -0
- package/dist/core/plugin/stringIpv4.d.ts +85 -0
- package/dist/core/plugin/stringIpv6.d.ts +104 -0
- package/dist/core/plugin/stringIri.d.ts +117 -0
- package/dist/core/plugin/stringIriReference.d.ts +43 -0
- package/dist/core/plugin/stringJsonPointer.d.ts +107 -0
- package/dist/core/plugin/stringMax.d.ts +43 -0
- package/dist/core/plugin/stringMin.d.ts +43 -0
- package/dist/core/plugin/stringPattern.d.ts +40 -0
- package/dist/core/plugin/stringRelativeJsonPointer.d.ts +42 -0
- package/dist/core/plugin/stringStartsWith.d.ts +42 -0
- package/dist/core/plugin/stringTime.d.ts +39 -0
- package/dist/core/plugin/stringUriTemplate.d.ts +43 -0
- package/dist/core/plugin/stringUrl.d.ts +97 -0
- package/dist/core/plugin/testUtils.d.ts +15 -0
- package/dist/core/plugin/transform-type-restrictions.d.ts +61 -0
- package/dist/core/plugin/transform.d.ts +35 -0
- package/dist/core/plugin/tupleBuilder.d.ts +66 -0
- package/dist/core/plugin/types.d.ts +143 -0
- package/dist/core/plugin/unionGuard.d.ts +50 -0
- package/dist/core/plugin/utils/field-accessor-optimized.d.ts +50 -0
- package/dist/core/plugin/utils/field-accessor.d.ts +107 -0
- package/dist/core/plugin/uuid.d.ts +95 -0
- package/dist/core/plugin/validateIf.d.ts +57 -0
- package/dist/core/registry/plugin-registry.d.ts +116 -0
- package/dist/core/registry.d.ts +6 -0
- package/dist/core/transform/index.d.ts +1 -0
- package/dist/core/transform/string/defaultValue.d.ts +6 -0
- package/dist/core/transform/string/index.d.ts +3 -0
- package/dist/core/transform/string/replace.d.ts +14 -0
- package/dist/core/transform/string/sanitize.d.ts +6 -0
- package/dist/core/utils/type-guards.d.ts +68 -0
- package/dist/index.d.ts +72 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +7 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +7 -0
- package/dist/plugins/arrayContains.d.ts +37 -0
- package/dist/plugins/arrayContains.js +1 -0
- package/dist/plugins/arrayContains.mjs +1 -0
- package/dist/plugins/arrayIncludes.d.ts +42 -0
- package/dist/plugins/arrayIncludes.js +1 -0
- package/dist/plugins/arrayIncludes.mjs +1 -0
- package/dist/plugins/arrayMaxLength.d.ts +43 -0
- package/dist/plugins/arrayMaxLength.js +1 -0
- package/dist/plugins/arrayMaxLength.mjs +1 -0
- package/dist/plugins/arrayMinLength.d.ts +43 -0
- package/dist/plugins/arrayMinLength.js +1 -0
- package/dist/plugins/arrayMinLength.mjs +1 -0
- package/dist/plugins/arrayUnique.d.ts +41 -0
- package/dist/plugins/arrayUnique.js +1 -0
- package/dist/plugins/arrayUnique.mjs +1 -0
- package/dist/plugins/booleanFalsy.d.ts +41 -0
- package/dist/plugins/booleanFalsy.js +1 -0
- package/dist/plugins/booleanFalsy.mjs +1 -0
- package/dist/plugins/booleanTruthy.d.ts +38 -0
- package/dist/plugins/booleanTruthy.js +1 -0
- package/dist/plugins/booleanTruthy.mjs +1 -0
- package/dist/plugins/compareField.d.ts +58 -0
- package/dist/plugins/compareField.js +1 -0
- package/dist/plugins/compareField.mjs +1 -0
- package/dist/plugins/custom.d.ts +60 -0
- package/dist/plugins/custom.js +1 -0
- package/dist/plugins/custom.mjs +1 -0
- package/dist/plugins/jsonSchema.d.ts +11 -0
- package/dist/plugins/jsonSchema.js +1 -0
- package/dist/plugins/jsonSchema.mjs +1 -0
- package/dist/plugins/jsonSchemaFullFeature.d.ts +31 -0
- package/dist/plugins/jsonSchemaFullFeature.js +1 -0
- package/dist/plugins/jsonSchemaFullFeature.mjs +1 -0
- package/dist/plugins/literal.d.ts +40 -0
- package/dist/plugins/literal.js +1 -0
- package/dist/plugins/literal.mjs +1 -0
- package/dist/plugins/nullable.d.ts +34 -0
- package/dist/plugins/nullable.js +1 -0
- package/dist/plugins/nullable.mjs +1 -0
- package/dist/plugins/numberInteger.d.ts +41 -0
- package/dist/plugins/numberInteger.js +1 -0
- package/dist/plugins/numberInteger.mjs +1 -0
- package/dist/plugins/numberMax.d.ts +49 -0
- package/dist/plugins/numberMax.js +1 -0
- package/dist/plugins/numberMax.mjs +1 -0
- package/dist/plugins/numberMin.d.ts +49 -0
- package/dist/plugins/numberMin.js +1 -0
- package/dist/plugins/numberMin.mjs +1 -0
- package/dist/plugins/numberMultipleOf.d.ts +42 -0
- package/dist/plugins/numberMultipleOf.js +1 -0
- package/dist/plugins/numberMultipleOf.mjs +1 -0
- package/dist/plugins/numberNegative.d.ts +41 -0
- package/dist/plugins/numberNegative.js +1 -0
- package/dist/plugins/numberNegative.mjs +1 -0
- package/dist/plugins/numberPositive.d.ts +41 -0
- package/dist/plugins/numberPositive.js +1 -0
- package/dist/plugins/numberPositive.mjs +1 -0
- package/dist/plugins/object.d.ts +43 -0
- package/dist/plugins/object.js +1 -0
- package/dist/plugins/object.mjs +1 -0
- package/dist/plugins/objectAdditionalProperties.d.ts +51 -0
- package/dist/plugins/objectAdditionalProperties.js +1 -0
- package/dist/plugins/objectAdditionalProperties.mjs +1 -0
- package/dist/plugins/objectDependentRequired.d.ts +42 -0
- package/dist/plugins/objectDependentRequired.js +1 -0
- package/dist/plugins/objectDependentRequired.mjs +1 -0
- package/dist/plugins/objectDependentSchemas.d.ts +40 -0
- package/dist/plugins/objectDependentSchemas.js +1 -0
- package/dist/plugins/objectDependentSchemas.mjs +1 -0
- package/dist/plugins/objectMaxProperties.d.ts +42 -0
- package/dist/plugins/objectMaxProperties.js +1 -0
- package/dist/plugins/objectMaxProperties.mjs +1 -0
- package/dist/plugins/objectMinProperties.d.ts +42 -0
- package/dist/plugins/objectMinProperties.js +1 -0
- package/dist/plugins/objectMinProperties.mjs +1 -0
- package/dist/plugins/objectPatternProperties.d.ts +46 -0
- package/dist/plugins/objectPatternProperties.js +1 -0
- package/dist/plugins/objectPatternProperties.mjs +1 -0
- package/dist/plugins/objectPropertyNames.d.ts +36 -0
- package/dist/plugins/objectPropertyNames.js +1 -0
- package/dist/plugins/objectPropertyNames.mjs +1 -0
- package/dist/plugins/oneOf.d.ts +44 -0
- package/dist/plugins/oneOf.js +1 -0
- package/dist/plugins/oneOf.mjs +1 -0
- package/dist/plugins/optional.d.ts +35 -0
- package/dist/plugins/optional.js +1 -0
- package/dist/plugins/optional.mjs +1 -0
- package/dist/plugins/readOnlyWriteOnly.d.ts +48 -0
- package/dist/plugins/readOnlyWriteOnly.js +1 -0
- package/dist/plugins/readOnlyWriteOnly.mjs +1 -0
- package/dist/plugins/required.d.ts +45 -0
- package/dist/plugins/required.js +1 -0
- package/dist/plugins/required.mjs +1 -0
- package/dist/plugins/requiredIf.d.ts +66 -0
- package/dist/plugins/requiredIf.js +1 -0
- package/dist/plugins/requiredIf.mjs +1 -0
- package/dist/plugins/skip.d.ts +57 -0
- package/dist/plugins/skip.js +1 -0
- package/dist/plugins/skip.mjs +1 -0
- package/dist/plugins/stringBase64.d.ts +119 -0
- package/dist/plugins/stringBase64.js +1 -0
- package/dist/plugins/stringBase64.mjs +1 -0
- package/dist/plugins/stringContentEncoding.d.ts +43 -0
- package/dist/plugins/stringContentEncoding.js +1 -0
- package/dist/plugins/stringContentEncoding.mjs +1 -0
- package/dist/plugins/stringContentMediaType.d.ts +47 -0
- package/dist/plugins/stringContentMediaType.js +1 -0
- package/dist/plugins/stringContentMediaType.mjs +1 -0
- package/dist/plugins/stringDate.d.ts +48 -0
- package/dist/plugins/stringDate.js +1 -0
- package/dist/plugins/stringDate.mjs +1 -0
- package/dist/plugins/stringDatetime.d.ts +108 -0
- package/dist/plugins/stringDatetime.js +1 -0
- package/dist/plugins/stringDatetime.mjs +1 -0
- package/dist/plugins/stringDuration.d.ts +41 -0
- package/dist/plugins/stringDuration.js +1 -0
- package/dist/plugins/stringDuration.mjs +1 -0
- package/dist/plugins/stringEmail.d.ts +81 -0
- package/dist/plugins/stringEmail.js +1 -0
- package/dist/plugins/stringEmail.mjs +1 -0
- package/dist/plugins/stringHostname.d.ts +104 -0
- package/dist/plugins/stringHostname.js +1 -0
- package/dist/plugins/stringHostname.mjs +1 -0
- package/dist/plugins/stringIpv4.d.ts +85 -0
- package/dist/plugins/stringIpv4.js +1 -0
- package/dist/plugins/stringIpv4.mjs +1 -0
- package/dist/plugins/stringIpv6.d.ts +104 -0
- package/dist/plugins/stringIpv6.js +1 -0
- package/dist/plugins/stringIpv6.mjs +1 -0
- package/dist/plugins/stringIri.d.ts +117 -0
- package/dist/plugins/stringIri.js +1 -0
- package/dist/plugins/stringIri.mjs +1 -0
- package/dist/plugins/stringIriReference.d.ts +43 -0
- package/dist/plugins/stringIriReference.js +1 -0
- package/dist/plugins/stringIriReference.mjs +1 -0
- package/dist/plugins/stringJsonPointer.d.ts +107 -0
- package/dist/plugins/stringJsonPointer.js +1 -0
- package/dist/plugins/stringJsonPointer.mjs +1 -0
- package/dist/plugins/stringMax.d.ts +43 -0
- package/dist/plugins/stringMax.js +1 -0
- package/dist/plugins/stringMax.mjs +1 -0
- package/dist/plugins/stringMin.d.ts +43 -0
- package/dist/plugins/stringMin.js +1 -0
- package/dist/plugins/stringMin.mjs +1 -0
- package/dist/plugins/stringPattern.d.ts +40 -0
- package/dist/plugins/stringPattern.js +1 -0
- package/dist/plugins/stringPattern.mjs +1 -0
- package/dist/plugins/stringRelativeJsonPointer.d.ts +42 -0
- package/dist/plugins/stringRelativeJsonPointer.js +1 -0
- package/dist/plugins/stringRelativeJsonPointer.mjs +1 -0
- package/dist/plugins/stringTime.d.ts +39 -0
- package/dist/plugins/stringTime.js +1 -0
- package/dist/plugins/stringTime.mjs +1 -0
- package/dist/plugins/stringUriTemplate.d.ts +43 -0
- package/dist/plugins/stringUriTemplate.js +1 -0
- package/dist/plugins/stringUriTemplate.mjs +1 -0
- package/dist/plugins/stringUrl.d.ts +97 -0
- package/dist/plugins/stringUrl.js +1 -0
- package/dist/plugins/stringUrl.mjs +1 -0
- package/dist/plugins/transform.d.ts +35 -0
- package/dist/plugins/transform.js +1 -0
- package/dist/plugins/transform.mjs +1 -0
- package/dist/plugins/tupleBuilder.d.ts +66 -0
- package/dist/plugins/tupleBuilder.js +1 -0
- package/dist/plugins/tupleBuilder.mjs +1 -0
- package/dist/plugins/uuid.d.ts +95 -0
- package/dist/plugins/uuid.js +1 -0
- package/dist/plugins/uuid.mjs +1 -0
- package/dist/plugins/validateIf.d.ts +57 -0
- package/dist/plugins/validateIf.js +1 -0
- package/dist/plugins/validateIf.mjs +1 -0
- package/dist/types/array-type-analysis.d.ts +115 -0
- package/dist/types/index.d.ts +74 -0
- package/dist/types/indexed-result.d.ts +44 -0
- package/dist/types/result.d.ts +159 -0
- package/dist/types/stitch-types.d.ts +118 -0
- package/dist/types/util.d.ts +19 -0
- package/dist/types/valitator.d.ts +10 -0
- package/package.json +353 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { TypedPlugin, TypeName, PluginCategory, BuilderExtensionPlugin, BuilderExtensionMethod } from "../plugins/plugin-types";
|
|
2
|
+
import { PluginImplementation } from "../types/types";
|
|
3
|
+
import { PredefinedTransformImplementation, ConfigurableTransformImplementation } from "../plugins/plugin-interfaces";
|
|
4
|
+
/**
|
|
5
|
+
* Plugin Creator with Type-Safe Interfaces (Optimized)
|
|
6
|
+
*
|
|
7
|
+
* This module provides an intuitive API for creating plugins
|
|
8
|
+
* with proper type guidance and IntelliSense support.
|
|
9
|
+
* Optimized for smaller bundle size while maintaining the same interface.
|
|
10
|
+
*/
|
|
11
|
+
export type { PluginImplementation, PluginDefinition } from "../types/types";
|
|
12
|
+
export declare function plugin<TPluginName extends string, TMethodName extends string, TTypes extends readonly TypeName[], TCategory extends PluginCategory, TImpl extends PluginImplementation<TCategory, TTypes>>(args: {
|
|
13
|
+
name: TPluginName;
|
|
14
|
+
methodName: TMethodName;
|
|
15
|
+
allowedTypes: TTypes;
|
|
16
|
+
category: TCategory;
|
|
17
|
+
impl: TImpl;
|
|
18
|
+
}): TypedPlugin<TPluginName, TMethodName, TImpl, TTypes, "validator", TCategory>;
|
|
19
|
+
export declare function pluginPredefinedTransform<TName extends string, TTypes extends readonly TypeName[], TInput, TOutput>(args: {
|
|
20
|
+
name: TName;
|
|
21
|
+
allowedTypes: TTypes;
|
|
22
|
+
impl: PredefinedTransformImplementation<TInput, TOutput>;
|
|
23
|
+
}): TypedPlugin<TName, TName, () => any, TTypes, "transform", "transform">;
|
|
24
|
+
export declare function pluginConfigurableTransform<TName extends string, TTypes extends readonly TypeName[], TConfig extends any[], TInput, TOutput>(args: {
|
|
25
|
+
name: TName;
|
|
26
|
+
allowedTypes: TTypes;
|
|
27
|
+
impl: ConfigurableTransformImplementation<TConfig, TInput, TOutput>;
|
|
28
|
+
}): TypedPlugin<TName, TName, (...args: TConfig) => any, TTypes, "transform", "transform">;
|
|
29
|
+
/**
|
|
30
|
+
* Builder extension plugin factory function
|
|
31
|
+
* Creates a plugin that extends the builder with additional methods
|
|
32
|
+
*/
|
|
33
|
+
export declare function pluginBuilderExtension<TName extends string, TMethodName extends string, TMethodSignature extends BuilderExtensionMethod = BuilderExtensionMethod>(args: {
|
|
34
|
+
name: TName;
|
|
35
|
+
methodName: TMethodName;
|
|
36
|
+
impl: () => TMethodSignature;
|
|
37
|
+
extendBuilder: (builderInstance: any) => void;
|
|
38
|
+
}): BuilderExtensionPlugin<TName, TMethodName, TMethodSignature>;
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type-safe Plugin Interfaces
|
|
3
|
+
*
|
|
4
|
+
* This module provides clear interfaces for each plugin category,
|
|
5
|
+
* making it easy for developers to create new plugins without confusion.
|
|
6
|
+
*/
|
|
7
|
+
import { ValidationFunction } from "../types/types";
|
|
8
|
+
import { NestedKeyOf, ValidationOptions, ValidationContext } from "../../plugin/types";
|
|
9
|
+
import { TypeName } from "./plugin-types";
|
|
10
|
+
/**
|
|
11
|
+
* Base validation result
|
|
12
|
+
*/
|
|
13
|
+
export type PluginValidationResult = {
|
|
14
|
+
valid: boolean;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Hoisted validator format for performance optimization
|
|
18
|
+
*/
|
|
19
|
+
export interface ValidatorFormat {
|
|
20
|
+
check: (value: any, allValues?: any, arrayContext?: import("../../plugin/types").ArrayContext) => boolean;
|
|
21
|
+
code: string;
|
|
22
|
+
getErrorMessage: (value: any, path: string, allValues?: any, arrayContext?: import("../../plugin/types").ArrayContext) => string;
|
|
23
|
+
params: any[];
|
|
24
|
+
isOptional?: boolean;
|
|
25
|
+
skipForUndefined?: boolean;
|
|
26
|
+
isNullable?: boolean;
|
|
27
|
+
skipForNull?: boolean;
|
|
28
|
+
__isTransform?: boolean;
|
|
29
|
+
__isDefault?: boolean;
|
|
30
|
+
__isPreprocess?: boolean;
|
|
31
|
+
__isFromContext?: boolean;
|
|
32
|
+
__isStitch?: boolean;
|
|
33
|
+
__isOrFail?: boolean;
|
|
34
|
+
__isRecursive?: boolean;
|
|
35
|
+
__transformFn?: (value: any) => any;
|
|
36
|
+
__contextOptions?: any;
|
|
37
|
+
__stitchOptions?: import("../../../types/stitch-types").TypeSafeStitchOptions<any, any, readonly (import("../../../types/util").NestedKeyOf<any> & string)[]>;
|
|
38
|
+
__condition?: (allValues: any, arrayContext?: import("../../plugin/types").ArrayContext) => boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Standard validation method interface
|
|
42
|
+
* Used for: min, max, required, pattern, etc.
|
|
43
|
+
*/
|
|
44
|
+
export interface StandardValidationMethod<TArgs extends any[] = any[], TTypes extends readonly TypeName[] = readonly TypeName[]> {
|
|
45
|
+
<TObject = any>(...args: TArgs): ValidationFunction<TObject, TTypes>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Standard plugin implementation helper
|
|
49
|
+
* Supports both legacy function format and new hoisted validator format
|
|
50
|
+
*/
|
|
51
|
+
export interface StandardPluginImplementation<TArgs extends any[] = any[], TTypes extends readonly TypeName[] = readonly TypeName[]> {
|
|
52
|
+
(...args: TArgs): ((value: TTypes extends readonly TypeName[] ? TTypes[number] extends TypeName ? import("../plugins/plugin-types").TypeMapping[TTypes[number]] : any : any, ctx: ValidationContext<any, any>) => PluginValidationResult) | ValidatorFormat;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Conditional validation method interface
|
|
56
|
+
* Used for: requiredIf, optionalIf, skip, validateIf
|
|
57
|
+
*/
|
|
58
|
+
export interface ConditionalValidationMethod<TTypes extends readonly TypeName[] = readonly TypeName[], TObjectPlaceholder = unknown, TInputPlaceholder = unknown> {
|
|
59
|
+
<TObject extends TObjectPlaceholder = any>(condition: (allValues: TObject) => boolean, options?: ValidationOptions): ValidationFunction<TObject, TTypes>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Multi-field reference validation method interface
|
|
63
|
+
* Used for: stitch plugin (cross-field validation with type safety)
|
|
64
|
+
*/
|
|
65
|
+
export interface MultiFieldReferenceValidationMethod<TTypes extends readonly TypeName[] = readonly TypeName[], TObjectPlaceholder = unknown, TCurrentFieldPlaceholder = unknown> {
|
|
66
|
+
<TObject extends TObjectPlaceholder = any, TCurrentField extends TCurrentFieldPlaceholder = any, const TFields extends readonly (NestedKeyOf<TObject> & string)[] = readonly (NestedKeyOf<TObject> & string)[]>(fields: TFields, validate: (fieldValues: import("../../../types/stitch-types").FieldsToObject<TObject, TFields>, currentValue: TCurrentField, allValues: TObject) => {
|
|
67
|
+
valid: boolean;
|
|
68
|
+
message?: string;
|
|
69
|
+
}, options?: ValidationOptions & {
|
|
70
|
+
code?: string;
|
|
71
|
+
messageFactory?: (context: {
|
|
72
|
+
path: string;
|
|
73
|
+
value: TCurrentField;
|
|
74
|
+
code: string;
|
|
75
|
+
fields: TFields;
|
|
76
|
+
fieldValues: import("../../../types/stitch-types").FieldsToObject<TObject, TFields>;
|
|
77
|
+
allValues: TObject;
|
|
78
|
+
}) => string;
|
|
79
|
+
}): ValidationFunction<TObject, TTypes>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Multi-field reference plugin implementation helper
|
|
83
|
+
* Provides complete type safety for cross-field validation plugins
|
|
84
|
+
*/
|
|
85
|
+
export interface MultiFieldReferencePluginImplementation<TTypes extends readonly TypeName[] = readonly TypeName[]> {
|
|
86
|
+
<TObject = any, TCurrentField = any, const TFields extends readonly (NestedKeyOf<TObject> & string)[] = readonly (NestedKeyOf<TObject> & string)[]>(fields: TFields, validate: (fieldValues: import("../../../types/stitch-types").FieldsToObject<TObject, TFields>, currentValue: TCurrentField, allValues: TObject) => {
|
|
87
|
+
valid: boolean;
|
|
88
|
+
message?: string;
|
|
89
|
+
}, options?: ValidationOptions & {
|
|
90
|
+
code?: string;
|
|
91
|
+
messageFactory?: (context: {
|
|
92
|
+
path: string;
|
|
93
|
+
value: TCurrentField;
|
|
94
|
+
code: string;
|
|
95
|
+
fields: TFields;
|
|
96
|
+
fieldValues: import("../../../types/stitch-types").FieldsToObject<TObject, TFields>;
|
|
97
|
+
allValues: TObject;
|
|
98
|
+
}) => string;
|
|
99
|
+
}): ValidatorFormat;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Conditional plugin implementation helper
|
|
103
|
+
* Supports both legacy function format and new hoisted validator format
|
|
104
|
+
*/
|
|
105
|
+
export interface ConditionalPluginImplementation<TTypes extends readonly TypeName[] = readonly TypeName[]> {
|
|
106
|
+
<TObject = any>(condition: (allValues: TObject, arrayContext?: import("../../plugin/types").ArrayContext) => boolean, options?: ValidationOptions): ((value: TTypes extends readonly TypeName[] ? TTypes[number] extends TypeName ? import("../plugins/plugin-types").TypeMapping[TTypes[number]] : any : any, ctx: ValidationContext<any, any>) => PluginValidationResult & {
|
|
107
|
+
__skipFurtherValidation?: boolean;
|
|
108
|
+
__skipAllValidation?: boolean;
|
|
109
|
+
}) | (ValidatorFormat & {
|
|
110
|
+
shouldSkipValidation?: (value: any, allValues?: any, arrayContext?: import("../../plugin/types").ArrayContext) => boolean;
|
|
111
|
+
shouldSkipAllValidation?: (value: any, allValues?: any, arrayContext?: import("../../plugin/types").ArrayContext) => boolean;
|
|
112
|
+
shouldSkipFurtherValidation?: (value: any, allValues?: any, arrayContext?: import("../../plugin/types").ArrayContext) => boolean;
|
|
113
|
+
evaluateCondition?: (allValues?: any, arrayContext?: import("../../plugin/types").ArrayContext) => boolean;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Field reference validation method interface
|
|
118
|
+
* Used for: compareField, differentFrom, etc.
|
|
119
|
+
*/
|
|
120
|
+
export interface FieldReferenceValidationMethod<TTypes extends readonly TypeName[] = readonly TypeName[], TObjectPlaceholder = unknown, TInputPlaceholder = unknown> {
|
|
121
|
+
<TObject extends TObjectPlaceholder = any>(fieldPath: NestedKeyOf<TObject> & string, options?: ValidationOptions): ValidationFunction<TObject, TTypes>;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Field reference plugin implementation helper
|
|
125
|
+
* Supports both legacy function format and new hoisted validator format
|
|
126
|
+
*/
|
|
127
|
+
export interface FieldReferencePluginImplementation<TTypes extends readonly TypeName[] = readonly TypeName[]> {
|
|
128
|
+
<TObject = any>(fieldPath: NestedKeyOf<TObject> & string, options?: ValidationOptions): ((value: TTypes extends readonly TypeName[] ? TTypes[number] extends TypeName ? import("../plugins/plugin-types").TypeMapping[TTypes[number]] : any : any, ctx: ValidationContext<any, any>) => PluginValidationResult) | (ValidatorFormat & {
|
|
129
|
+
fieldReference?: {
|
|
130
|
+
fieldPath: string;
|
|
131
|
+
compareFn?: string | ((value: any, targetValue: any) => boolean);
|
|
132
|
+
};
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Transform method interface
|
|
137
|
+
* Used for: transform
|
|
138
|
+
*/
|
|
139
|
+
export interface TransformValidationMethod<TTypes extends readonly TypeName[] = readonly TypeName[]> {
|
|
140
|
+
<TObject = any, TInput = any, TOutput = any>(transformFn: (value: TInput) => TOutput): ValidationFunction<TObject, TTypes>;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Base transform result with generics
|
|
144
|
+
*/
|
|
145
|
+
export interface TransformResult<TInput, TOutput> extends PluginValidationResult {
|
|
146
|
+
__isTransform: true;
|
|
147
|
+
__transformFn: (value: TInput) => TOutput;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Predefined transform implementation (e.g., toUpperCase, toLowerCase)
|
|
151
|
+
* No arguments, transform is predefined
|
|
152
|
+
*/
|
|
153
|
+
export interface PredefinedTransformImplementation<TInput, TOutput> {
|
|
154
|
+
(): (value: TInput, ctx: ValidationContext<any, any>) => TransformResult<TInput, TOutput>;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Configurable transform implementation (e.g., toFixed(2), split(','))
|
|
158
|
+
* Takes configuration arguments
|
|
159
|
+
*/
|
|
160
|
+
export interface ConfigurableTransformImplementation<TConfig extends any[], TInput, TOutput> {
|
|
161
|
+
(...config: TConfig): (value: TInput, ctx: ValidationContext<any, any>) => TransformResult<TInput, TOutput>;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Generic transform implementation (e.g., transform(fn))
|
|
165
|
+
* Takes a user-defined transform function
|
|
166
|
+
*/
|
|
167
|
+
export interface GenericTransformImplementation {
|
|
168
|
+
<TInput, TOutput>(transformFn: (value: TInput) => TOutput): (value: TInput, ctx: ValidationContext<any, any>) => TransformResult<TInput, TOutput>;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Union type for all transform implementations
|
|
172
|
+
* Supports both legacy function format and new hoisted validator format
|
|
173
|
+
*/
|
|
174
|
+
export type TransformPluginImplementation<TInput = any, TOutput = any> = PredefinedTransformImplementation<TInput, TOutput> | ConfigurableTransformImplementation<any[], TInput, TOutput> | GenericTransformImplementation | (<TInputActual = TInput, TOutputActual = TOutput>(transformFn: (value: TInputActual) => TOutputActual, options?: ValidationOptions) => ValidatorFormat);
|
|
175
|
+
/**
|
|
176
|
+
* Array element validation method interface
|
|
177
|
+
* Used for: includes, excludes
|
|
178
|
+
*/
|
|
179
|
+
export interface ArrayElementValidationMethod {
|
|
180
|
+
<TObject = any, TElement = any>(element: TElement, options?: ValidationOptions): ValidationFunction<TObject, readonly ["array"]>;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Array element plugin implementation helper
|
|
184
|
+
* Supports both legacy function format and new hoisted validator format
|
|
185
|
+
*/
|
|
186
|
+
export interface ArrayElementPluginImplementation {
|
|
187
|
+
<TElement = any>(element: TElement, options?: ValidationOptions): ((value: TElement[], ctx: ValidationContext<any, any>) => PluginValidationResult) | ValidatorFormat;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Plugin category specifications with clear interfaces
|
|
191
|
+
*/
|
|
192
|
+
export declare const PluginCategories: {
|
|
193
|
+
/**
|
|
194
|
+
* Standard validation plugins
|
|
195
|
+
* Examples: required, min, max, pattern, email, url
|
|
196
|
+
*/
|
|
197
|
+
readonly standard: {
|
|
198
|
+
readonly description: "Basic validation with fixed arguments";
|
|
199
|
+
readonly examples: readonly ["required", "min", "max", "pattern", "email", "url"];
|
|
200
|
+
readonly interface: StandardValidationMethod;
|
|
201
|
+
readonly implementation: StandardPluginImplementation;
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Conditional validation plugins
|
|
205
|
+
* Examples: requiredIf, optionalIf, skip, validateIf
|
|
206
|
+
*/
|
|
207
|
+
readonly conditional: {
|
|
208
|
+
readonly description: "Validation that depends on other field values";
|
|
209
|
+
readonly examples: readonly ["requiredIf", "optionalIf", "skip", "validateIf"];
|
|
210
|
+
readonly interface: ConditionalValidationMethod;
|
|
211
|
+
readonly implementation: ConditionalPluginImplementation;
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* Field reference plugins
|
|
215
|
+
* Examples: compareField, differentFrom, greaterThanField
|
|
216
|
+
*/
|
|
217
|
+
readonly fieldReference: {
|
|
218
|
+
readonly description: "Validation that compares with other fields";
|
|
219
|
+
readonly examples: readonly ["compareField", "differentFrom", "greaterThanField"];
|
|
220
|
+
readonly interface: FieldReferenceValidationMethod;
|
|
221
|
+
readonly implementation: FieldReferencePluginImplementation;
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* Transform plugins
|
|
225
|
+
* Examples: transform, parse, format
|
|
226
|
+
*/
|
|
227
|
+
readonly transform: {
|
|
228
|
+
readonly description: "Plugins that transform values";
|
|
229
|
+
readonly examples: readonly ["transform", "parse", "format"];
|
|
230
|
+
readonly interface: TransformValidationMethod;
|
|
231
|
+
readonly implementation: TransformPluginImplementation;
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Array element plugins
|
|
235
|
+
* Examples: includes, excludes, every, some
|
|
236
|
+
*/
|
|
237
|
+
readonly arrayElement: {
|
|
238
|
+
readonly description: "Array-specific validation with element type awareness";
|
|
239
|
+
readonly examples: readonly ["includes", "excludes", "every", "some"];
|
|
240
|
+
readonly interface: ArrayElementValidationMethod;
|
|
241
|
+
readonly implementation: ArrayElementPluginImplementation;
|
|
242
|
+
};
|
|
243
|
+
/**
|
|
244
|
+
* Context-based plugins
|
|
245
|
+
* Examples: fromContext, withAsyncData, crossReference
|
|
246
|
+
*/
|
|
247
|
+
readonly context: {
|
|
248
|
+
readonly description: "Validation using external context data (async or sync)";
|
|
249
|
+
readonly examples: readonly ["fromContext", "withAsyncData", "crossReference"];
|
|
250
|
+
readonly interface: ContextValidationMethod;
|
|
251
|
+
readonly implementation: ContextPluginImplementation;
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Multi-field reference plugins
|
|
255
|
+
* Examples: stitch (cross-field validation with type safety)
|
|
256
|
+
*/
|
|
257
|
+
readonly multiFieldReference: {
|
|
258
|
+
readonly description: "Type-safe validation that depends on multiple fields with compile-time field path validation";
|
|
259
|
+
readonly examples: readonly ["stitch", "crossFieldValidation", "conditionalRequirement"];
|
|
260
|
+
readonly interface: MultiFieldReferenceValidationMethod;
|
|
261
|
+
readonly implementation: MultiFieldReferencePluginImplementation;
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* Helper type to get implementation type from category
|
|
266
|
+
*/
|
|
267
|
+
export type GetImplementationType<TCategory extends keyof typeof PluginCategories> = (typeof PluginCategories)[TCategory]["implementation"];
|
|
268
|
+
/**
|
|
269
|
+
* Helper type to get interface type from category
|
|
270
|
+
*/
|
|
271
|
+
export type GetInterfaceType<TCategory extends keyof typeof PluginCategories> = (typeof PluginCategories)[TCategory]["interface"];
|
|
272
|
+
/**
|
|
273
|
+
* Context validation method interface
|
|
274
|
+
* Used for: fromContext, withAsyncData, crossReference
|
|
275
|
+
*/
|
|
276
|
+
export interface ContextValidationMethod<TTypes extends readonly TypeName[] = readonly TypeName[]> {
|
|
277
|
+
<TObject = any, TContext = any>(contextOptions: ContextValidationOptions<TContext>): ValidationFunction<TObject, TTypes>;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Context validation options
|
|
281
|
+
*/
|
|
282
|
+
export interface ContextValidationOptions<TContext = any> {
|
|
283
|
+
/**
|
|
284
|
+
* Validation function that receives value, context data, and allValues
|
|
285
|
+
*/
|
|
286
|
+
validate: (value: any, context: TContext, allValues: any) => {
|
|
287
|
+
valid: boolean;
|
|
288
|
+
message?: string;
|
|
289
|
+
};
|
|
290
|
+
/** Custom error message */
|
|
291
|
+
errorMessage?: string;
|
|
292
|
+
/** Error code for validation issues */
|
|
293
|
+
code?: string;
|
|
294
|
+
/** Whether context data is required (default: false) */
|
|
295
|
+
required?: boolean;
|
|
296
|
+
/** Whether to return valid when context is unavailable (default: true) */
|
|
297
|
+
fallbackToValid?: boolean;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Context plugin implementation helper
|
|
301
|
+
* Supports both legacy function format and new hoisted validator format
|
|
302
|
+
*/
|
|
303
|
+
export interface ContextPluginImplementation<TTypes extends readonly TypeName[] = readonly TypeName[]> {
|
|
304
|
+
<TContext = any>(options: ContextValidationOptions<TContext>): ((value: TTypes extends readonly TypeName[] ? TTypes[number] extends TypeName ? import("../plugins/plugin-types").TypeMapping[TTypes[number]] : any : any, ctx: ValidationContext<any, any>) => PluginValidationResult) | (ValidatorFormat & {
|
|
305
|
+
fromContext?: {
|
|
306
|
+
options: ContextValidationOptions<TContext>;
|
|
307
|
+
required: boolean;
|
|
308
|
+
fallbackToValid: boolean;
|
|
309
|
+
errorMessage?: string;
|
|
310
|
+
performContextValidation: (value: any, ctx: any) => any;
|
|
311
|
+
};
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Preprocessor validation method interface
|
|
316
|
+
* Used for: coerce, default, preprocess
|
|
317
|
+
*/
|
|
318
|
+
export interface PreprocessorValidationMethod<TTypes extends readonly TypeName[] = readonly TypeName[]> {
|
|
319
|
+
<TObject = any>(): any;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Preprocessor plugin implementation helper
|
|
323
|
+
* Supports both legacy function format and new hoisted validator format
|
|
324
|
+
*/
|
|
325
|
+
export interface PreprocessorPluginImplementation<TTypes extends readonly TypeName[] = readonly TypeName[]> {
|
|
326
|
+
(...args: any[]): ((value: any, ctx?: ValidationContext<any, any>) => any) | (ValidatorFormat & {
|
|
327
|
+
coerce?: {
|
|
328
|
+
targetType: string;
|
|
329
|
+
coerceFn: (value: any) => any;
|
|
330
|
+
options?: ValidationOptions;
|
|
331
|
+
};
|
|
332
|
+
default?: {
|
|
333
|
+
defaultValue: any;
|
|
334
|
+
options?: ValidationOptions;
|
|
335
|
+
applyDefault: (value: any, ctx: any) => any;
|
|
336
|
+
};
|
|
337
|
+
preprocess?: {
|
|
338
|
+
preprocessFn: (value: any) => any;
|
|
339
|
+
options?: ValidationOptions;
|
|
340
|
+
applyPreprocess: (value: any, ctx: any) => any;
|
|
341
|
+
};
|
|
342
|
+
});
|
|
343
|
+
}
|