@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.
Files changed (312) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +879 -0
  3. package/dist/constants.d.ts +27 -0
  4. package/dist/core/async.experimental/async-context.d.ts +60 -0
  5. package/dist/core/builder/array-batch-optimizer.d.ts +66 -0
  6. package/dist/core/builder/context/field-context.d.ts +31 -0
  7. package/dist/core/builder/context/field-type-detector.d.ts +19 -0
  8. package/dist/core/builder/core/builder.d.ts +10 -0
  9. package/dist/core/builder/core/field-builder.d.ts +13 -0
  10. package/dist/core/builder/core/index.d.ts +17 -0
  11. package/dist/core/builder/index.d.ts +24 -0
  12. package/dist/core/builder/nested-array-processor.d.ts +52 -0
  13. package/dist/core/builder/plugins/composable-conditional-plugin.d.ts +32 -0
  14. package/dist/core/builder/plugins/composable-directly-plugin.d.ts +32 -0
  15. package/dist/core/builder/plugins/composable-plugin.d.ts +242 -0
  16. package/dist/core/builder/plugins/plugin-creator.d.ts +38 -0
  17. package/dist/core/builder/plugins/plugin-interfaces.d.ts +343 -0
  18. package/dist/core/builder/plugins/plugin-types.d.ts +441 -0
  19. package/dist/core/builder/raw-validator.d.ts +22 -0
  20. package/dist/core/builder/types/field-options.d.ts +46 -0
  21. package/dist/core/builder/types/types.d.ts +318 -0
  22. package/dist/core/builder/ultra-fast-validator.d.ts +30 -0
  23. package/dist/core/builder/validator-factory.d.ts +29 -0
  24. package/dist/core/global-config.d.ts +27 -0
  25. package/dist/core/index.d.ts +36 -0
  26. package/dist/core/optimization/array-batch-validator.d.ts +68 -0
  27. package/dist/core/optimization/core/field-utils.d.ts +103 -0
  28. package/dist/core/optimization/core/strategy-factory.d.ts +84 -0
  29. package/dist/core/optimization/core/validation-engine.d.ts +107 -0
  30. package/dist/core/optimization/execution-strategy-selector.d.ts +23 -0
  31. package/dist/core/optimization/unified-validator.d.ts +45 -0
  32. package/dist/core/plugin/__tests__/test-utils.d.ts +1 -0
  33. package/dist/core/plugin/arrayContains.d.ts +37 -0
  34. package/dist/core/plugin/arrayIncludes.d.ts +42 -0
  35. package/dist/core/plugin/arrayMaxLength.d.ts +43 -0
  36. package/dist/core/plugin/arrayMinLength.d.ts +43 -0
  37. package/dist/core/plugin/arrayUnique.d.ts +41 -0
  38. package/dist/core/plugin/booleanFalsy.d.ts +41 -0
  39. package/dist/core/plugin/booleanTruthy.d.ts +38 -0
  40. package/dist/core/plugin/compareField.d.ts +58 -0
  41. package/dist/core/plugin/conditionalSchema.d.ts +24 -0
  42. package/dist/core/plugin/custom.d.ts +60 -0
  43. package/dist/core/plugin/fromContext.d.ts +150 -0
  44. package/dist/core/plugin/index.d.ts +71 -0
  45. package/dist/core/plugin/jsonSchema/dsl-converter.d.ts +22 -0
  46. package/dist/core/plugin/jsonSchema/error-generation.d.ts +14 -0
  47. package/dist/core/plugin/jsonSchema/format-validators.d.ts +20 -0
  48. package/dist/core/plugin/jsonSchema/index.d.ts +11 -0
  49. package/dist/core/plugin/jsonSchema/plugin.d.ts +35 -0
  50. package/dist/core/plugin/jsonSchema/ref-resolver.d.ts +14 -0
  51. package/dist/core/plugin/jsonSchema/types.d.ts +69 -0
  52. package/dist/core/plugin/jsonSchema/validation-core.d.ts +29 -0
  53. package/dist/core/plugin/jsonSchemaFullFeature.d.ts +31 -0
  54. package/dist/core/plugin/literal.d.ts +40 -0
  55. package/dist/core/plugin/message-factories.d.ts +9 -0
  56. package/dist/core/plugin/nullable.d.ts +34 -0
  57. package/dist/core/plugin/numberFinite.d.ts +41 -0
  58. package/dist/core/plugin/numberInteger.d.ts +41 -0
  59. package/dist/core/plugin/numberMax.d.ts +49 -0
  60. package/dist/core/plugin/numberMin.d.ts +49 -0
  61. package/dist/core/plugin/numberMultipleOf.d.ts +42 -0
  62. package/dist/core/plugin/numberNegative.d.ts +41 -0
  63. package/dist/core/plugin/numberPositive.d.ts +41 -0
  64. package/dist/core/plugin/numberRange.d.ts +48 -0
  65. package/dist/core/plugin/object.d.ts +43 -0
  66. package/dist/core/plugin/objectAdditionalProperties.d.ts +51 -0
  67. package/dist/core/plugin/objectDependentRequired.d.ts +42 -0
  68. package/dist/core/plugin/objectDependentSchemas.d.ts +40 -0
  69. package/dist/core/plugin/objectMaxProperties.d.ts +42 -0
  70. package/dist/core/plugin/objectMinProperties.d.ts +42 -0
  71. package/dist/core/plugin/objectPatternProperties.d.ts +46 -0
  72. package/dist/core/plugin/objectPropertyNames.d.ts +36 -0
  73. package/dist/core/plugin/objectRecursively.d.ts +81 -0
  74. package/dist/core/plugin/oneOf.d.ts +44 -0
  75. package/dist/core/plugin/optional.d.ts +35 -0
  76. package/dist/core/plugin/optionalIf.d.ts +42 -0
  77. package/dist/core/plugin/orFail.d.ts +132 -0
  78. package/dist/core/plugin/readOnlyWriteOnly.d.ts +48 -0
  79. package/dist/core/plugin/required.d.ts +45 -0
  80. package/dist/core/plugin/requiredIf.d.ts +66 -0
  81. package/dist/core/plugin/shared-constants.d.ts +45 -0
  82. package/dist/core/plugin/shared.d.ts +3 -0
  83. package/dist/core/plugin/skip.d.ts +57 -0
  84. package/dist/core/plugin/stitch-typed.d.ts +15 -0
  85. package/dist/core/plugin/stitch.d.ts +1 -0
  86. package/dist/core/plugin/stitchSimple.d.ts +4 -0
  87. package/dist/core/plugin/stringAlphanumeric.d.ts +42 -0
  88. package/dist/core/plugin/stringBase64.d.ts +119 -0
  89. package/dist/core/plugin/stringContentEncoding.d.ts +43 -0
  90. package/dist/core/plugin/stringContentMediaType.d.ts +47 -0
  91. package/dist/core/plugin/stringDate.d.ts +48 -0
  92. package/dist/core/plugin/stringDatetime.d.ts +108 -0
  93. package/dist/core/plugin/stringDuration.d.ts +41 -0
  94. package/dist/core/plugin/stringEmail.d.ts +81 -0
  95. package/dist/core/plugin/stringEndsWith.d.ts +42 -0
  96. package/dist/core/plugin/stringExactLength.d.ts +46 -0
  97. package/dist/core/plugin/stringHostname.d.ts +104 -0
  98. package/dist/core/plugin/stringIpv4.d.ts +85 -0
  99. package/dist/core/plugin/stringIpv6.d.ts +104 -0
  100. package/dist/core/plugin/stringIri.d.ts +117 -0
  101. package/dist/core/plugin/stringIriReference.d.ts +43 -0
  102. package/dist/core/plugin/stringJsonPointer.d.ts +107 -0
  103. package/dist/core/plugin/stringMax.d.ts +43 -0
  104. package/dist/core/plugin/stringMin.d.ts +43 -0
  105. package/dist/core/plugin/stringPattern.d.ts +40 -0
  106. package/dist/core/plugin/stringRelativeJsonPointer.d.ts +42 -0
  107. package/dist/core/plugin/stringStartsWith.d.ts +42 -0
  108. package/dist/core/plugin/stringTime.d.ts +39 -0
  109. package/dist/core/plugin/stringUriTemplate.d.ts +43 -0
  110. package/dist/core/plugin/stringUrl.d.ts +97 -0
  111. package/dist/core/plugin/testUtils.d.ts +15 -0
  112. package/dist/core/plugin/transform-type-restrictions.d.ts +61 -0
  113. package/dist/core/plugin/transform.d.ts +35 -0
  114. package/dist/core/plugin/tupleBuilder.d.ts +66 -0
  115. package/dist/core/plugin/types.d.ts +143 -0
  116. package/dist/core/plugin/unionGuard.d.ts +50 -0
  117. package/dist/core/plugin/utils/field-accessor-optimized.d.ts +50 -0
  118. package/dist/core/plugin/utils/field-accessor.d.ts +107 -0
  119. package/dist/core/plugin/uuid.d.ts +95 -0
  120. package/dist/core/plugin/validateIf.d.ts +57 -0
  121. package/dist/core/registry/plugin-registry.d.ts +116 -0
  122. package/dist/core/registry.d.ts +6 -0
  123. package/dist/core/transform/index.d.ts +1 -0
  124. package/dist/core/transform/string/defaultValue.d.ts +6 -0
  125. package/dist/core/transform/string/index.d.ts +3 -0
  126. package/dist/core/transform/string/replace.d.ts +14 -0
  127. package/dist/core/transform/string/sanitize.d.ts +6 -0
  128. package/dist/core/utils/type-guards.d.ts +68 -0
  129. package/dist/index.d.ts +72 -0
  130. package/dist/index.js +2 -0
  131. package/dist/index.js.map +7 -0
  132. package/dist/index.mjs +2 -0
  133. package/dist/index.mjs.map +7 -0
  134. package/dist/plugins/arrayContains.d.ts +37 -0
  135. package/dist/plugins/arrayContains.js +1 -0
  136. package/dist/plugins/arrayContains.mjs +1 -0
  137. package/dist/plugins/arrayIncludes.d.ts +42 -0
  138. package/dist/plugins/arrayIncludes.js +1 -0
  139. package/dist/plugins/arrayIncludes.mjs +1 -0
  140. package/dist/plugins/arrayMaxLength.d.ts +43 -0
  141. package/dist/plugins/arrayMaxLength.js +1 -0
  142. package/dist/plugins/arrayMaxLength.mjs +1 -0
  143. package/dist/plugins/arrayMinLength.d.ts +43 -0
  144. package/dist/plugins/arrayMinLength.js +1 -0
  145. package/dist/plugins/arrayMinLength.mjs +1 -0
  146. package/dist/plugins/arrayUnique.d.ts +41 -0
  147. package/dist/plugins/arrayUnique.js +1 -0
  148. package/dist/plugins/arrayUnique.mjs +1 -0
  149. package/dist/plugins/booleanFalsy.d.ts +41 -0
  150. package/dist/plugins/booleanFalsy.js +1 -0
  151. package/dist/plugins/booleanFalsy.mjs +1 -0
  152. package/dist/plugins/booleanTruthy.d.ts +38 -0
  153. package/dist/plugins/booleanTruthy.js +1 -0
  154. package/dist/plugins/booleanTruthy.mjs +1 -0
  155. package/dist/plugins/compareField.d.ts +58 -0
  156. package/dist/plugins/compareField.js +1 -0
  157. package/dist/plugins/compareField.mjs +1 -0
  158. package/dist/plugins/custom.d.ts +60 -0
  159. package/dist/plugins/custom.js +1 -0
  160. package/dist/plugins/custom.mjs +1 -0
  161. package/dist/plugins/jsonSchema.d.ts +11 -0
  162. package/dist/plugins/jsonSchema.js +1 -0
  163. package/dist/plugins/jsonSchema.mjs +1 -0
  164. package/dist/plugins/jsonSchemaFullFeature.d.ts +31 -0
  165. package/dist/plugins/jsonSchemaFullFeature.js +1 -0
  166. package/dist/plugins/jsonSchemaFullFeature.mjs +1 -0
  167. package/dist/plugins/literal.d.ts +40 -0
  168. package/dist/plugins/literal.js +1 -0
  169. package/dist/plugins/literal.mjs +1 -0
  170. package/dist/plugins/nullable.d.ts +34 -0
  171. package/dist/plugins/nullable.js +1 -0
  172. package/dist/plugins/nullable.mjs +1 -0
  173. package/dist/plugins/numberInteger.d.ts +41 -0
  174. package/dist/plugins/numberInteger.js +1 -0
  175. package/dist/plugins/numberInteger.mjs +1 -0
  176. package/dist/plugins/numberMax.d.ts +49 -0
  177. package/dist/plugins/numberMax.js +1 -0
  178. package/dist/plugins/numberMax.mjs +1 -0
  179. package/dist/plugins/numberMin.d.ts +49 -0
  180. package/dist/plugins/numberMin.js +1 -0
  181. package/dist/plugins/numberMin.mjs +1 -0
  182. package/dist/plugins/numberMultipleOf.d.ts +42 -0
  183. package/dist/plugins/numberMultipleOf.js +1 -0
  184. package/dist/plugins/numberMultipleOf.mjs +1 -0
  185. package/dist/plugins/numberNegative.d.ts +41 -0
  186. package/dist/plugins/numberNegative.js +1 -0
  187. package/dist/plugins/numberNegative.mjs +1 -0
  188. package/dist/plugins/numberPositive.d.ts +41 -0
  189. package/dist/plugins/numberPositive.js +1 -0
  190. package/dist/plugins/numberPositive.mjs +1 -0
  191. package/dist/plugins/object.d.ts +43 -0
  192. package/dist/plugins/object.js +1 -0
  193. package/dist/plugins/object.mjs +1 -0
  194. package/dist/plugins/objectAdditionalProperties.d.ts +51 -0
  195. package/dist/plugins/objectAdditionalProperties.js +1 -0
  196. package/dist/plugins/objectAdditionalProperties.mjs +1 -0
  197. package/dist/plugins/objectDependentRequired.d.ts +42 -0
  198. package/dist/plugins/objectDependentRequired.js +1 -0
  199. package/dist/plugins/objectDependentRequired.mjs +1 -0
  200. package/dist/plugins/objectDependentSchemas.d.ts +40 -0
  201. package/dist/plugins/objectDependentSchemas.js +1 -0
  202. package/dist/plugins/objectDependentSchemas.mjs +1 -0
  203. package/dist/plugins/objectMaxProperties.d.ts +42 -0
  204. package/dist/plugins/objectMaxProperties.js +1 -0
  205. package/dist/plugins/objectMaxProperties.mjs +1 -0
  206. package/dist/plugins/objectMinProperties.d.ts +42 -0
  207. package/dist/plugins/objectMinProperties.js +1 -0
  208. package/dist/plugins/objectMinProperties.mjs +1 -0
  209. package/dist/plugins/objectPatternProperties.d.ts +46 -0
  210. package/dist/plugins/objectPatternProperties.js +1 -0
  211. package/dist/plugins/objectPatternProperties.mjs +1 -0
  212. package/dist/plugins/objectPropertyNames.d.ts +36 -0
  213. package/dist/plugins/objectPropertyNames.js +1 -0
  214. package/dist/plugins/objectPropertyNames.mjs +1 -0
  215. package/dist/plugins/oneOf.d.ts +44 -0
  216. package/dist/plugins/oneOf.js +1 -0
  217. package/dist/plugins/oneOf.mjs +1 -0
  218. package/dist/plugins/optional.d.ts +35 -0
  219. package/dist/plugins/optional.js +1 -0
  220. package/dist/plugins/optional.mjs +1 -0
  221. package/dist/plugins/readOnlyWriteOnly.d.ts +48 -0
  222. package/dist/plugins/readOnlyWriteOnly.js +1 -0
  223. package/dist/plugins/readOnlyWriteOnly.mjs +1 -0
  224. package/dist/plugins/required.d.ts +45 -0
  225. package/dist/plugins/required.js +1 -0
  226. package/dist/plugins/required.mjs +1 -0
  227. package/dist/plugins/requiredIf.d.ts +66 -0
  228. package/dist/plugins/requiredIf.js +1 -0
  229. package/dist/plugins/requiredIf.mjs +1 -0
  230. package/dist/plugins/skip.d.ts +57 -0
  231. package/dist/plugins/skip.js +1 -0
  232. package/dist/plugins/skip.mjs +1 -0
  233. package/dist/plugins/stringBase64.d.ts +119 -0
  234. package/dist/plugins/stringBase64.js +1 -0
  235. package/dist/plugins/stringBase64.mjs +1 -0
  236. package/dist/plugins/stringContentEncoding.d.ts +43 -0
  237. package/dist/plugins/stringContentEncoding.js +1 -0
  238. package/dist/plugins/stringContentEncoding.mjs +1 -0
  239. package/dist/plugins/stringContentMediaType.d.ts +47 -0
  240. package/dist/plugins/stringContentMediaType.js +1 -0
  241. package/dist/plugins/stringContentMediaType.mjs +1 -0
  242. package/dist/plugins/stringDate.d.ts +48 -0
  243. package/dist/plugins/stringDate.js +1 -0
  244. package/dist/plugins/stringDate.mjs +1 -0
  245. package/dist/plugins/stringDatetime.d.ts +108 -0
  246. package/dist/plugins/stringDatetime.js +1 -0
  247. package/dist/plugins/stringDatetime.mjs +1 -0
  248. package/dist/plugins/stringDuration.d.ts +41 -0
  249. package/dist/plugins/stringDuration.js +1 -0
  250. package/dist/plugins/stringDuration.mjs +1 -0
  251. package/dist/plugins/stringEmail.d.ts +81 -0
  252. package/dist/plugins/stringEmail.js +1 -0
  253. package/dist/plugins/stringEmail.mjs +1 -0
  254. package/dist/plugins/stringHostname.d.ts +104 -0
  255. package/dist/plugins/stringHostname.js +1 -0
  256. package/dist/plugins/stringHostname.mjs +1 -0
  257. package/dist/plugins/stringIpv4.d.ts +85 -0
  258. package/dist/plugins/stringIpv4.js +1 -0
  259. package/dist/plugins/stringIpv4.mjs +1 -0
  260. package/dist/plugins/stringIpv6.d.ts +104 -0
  261. package/dist/plugins/stringIpv6.js +1 -0
  262. package/dist/plugins/stringIpv6.mjs +1 -0
  263. package/dist/plugins/stringIri.d.ts +117 -0
  264. package/dist/plugins/stringIri.js +1 -0
  265. package/dist/plugins/stringIri.mjs +1 -0
  266. package/dist/plugins/stringIriReference.d.ts +43 -0
  267. package/dist/plugins/stringIriReference.js +1 -0
  268. package/dist/plugins/stringIriReference.mjs +1 -0
  269. package/dist/plugins/stringJsonPointer.d.ts +107 -0
  270. package/dist/plugins/stringJsonPointer.js +1 -0
  271. package/dist/plugins/stringJsonPointer.mjs +1 -0
  272. package/dist/plugins/stringMax.d.ts +43 -0
  273. package/dist/plugins/stringMax.js +1 -0
  274. package/dist/plugins/stringMax.mjs +1 -0
  275. package/dist/plugins/stringMin.d.ts +43 -0
  276. package/dist/plugins/stringMin.js +1 -0
  277. package/dist/plugins/stringMin.mjs +1 -0
  278. package/dist/plugins/stringPattern.d.ts +40 -0
  279. package/dist/plugins/stringPattern.js +1 -0
  280. package/dist/plugins/stringPattern.mjs +1 -0
  281. package/dist/plugins/stringRelativeJsonPointer.d.ts +42 -0
  282. package/dist/plugins/stringRelativeJsonPointer.js +1 -0
  283. package/dist/plugins/stringRelativeJsonPointer.mjs +1 -0
  284. package/dist/plugins/stringTime.d.ts +39 -0
  285. package/dist/plugins/stringTime.js +1 -0
  286. package/dist/plugins/stringTime.mjs +1 -0
  287. package/dist/plugins/stringUriTemplate.d.ts +43 -0
  288. package/dist/plugins/stringUriTemplate.js +1 -0
  289. package/dist/plugins/stringUriTemplate.mjs +1 -0
  290. package/dist/plugins/stringUrl.d.ts +97 -0
  291. package/dist/plugins/stringUrl.js +1 -0
  292. package/dist/plugins/stringUrl.mjs +1 -0
  293. package/dist/plugins/transform.d.ts +35 -0
  294. package/dist/plugins/transform.js +1 -0
  295. package/dist/plugins/transform.mjs +1 -0
  296. package/dist/plugins/tupleBuilder.d.ts +66 -0
  297. package/dist/plugins/tupleBuilder.js +1 -0
  298. package/dist/plugins/tupleBuilder.mjs +1 -0
  299. package/dist/plugins/uuid.d.ts +95 -0
  300. package/dist/plugins/uuid.js +1 -0
  301. package/dist/plugins/uuid.mjs +1 -0
  302. package/dist/plugins/validateIf.d.ts +57 -0
  303. package/dist/plugins/validateIf.js +1 -0
  304. package/dist/plugins/validateIf.mjs +1 -0
  305. package/dist/types/array-type-analysis.d.ts +115 -0
  306. package/dist/types/index.d.ts +74 -0
  307. package/dist/types/indexed-result.d.ts +44 -0
  308. package/dist/types/result.d.ts +159 -0
  309. package/dist/types/stitch-types.d.ts +118 -0
  310. package/dist/types/util.d.ts +19 -0
  311. package/dist/types/valitator.d.ts +10 -0
  312. package/package.json +353 -0
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Strategy Pattern Implementation
3
+ * Validation strategy integration and factory pattern
4
+ */
5
+ import { ValidationEngine, ValidationField, ValidationResult, ParseResult } from "./validation-engine";
6
+ export declare enum ValidationStrategy {
7
+ FAST_SEPARATED = "fast_separated",
8
+ DEFINITION_ORDER = "definition_order",
9
+ ARRAY_BATCH = "array_batch",
10
+ HOISTED_OPTIMIZED = "hoisted_optimized"
11
+ }
12
+ export interface StrategyValidationOptions {
13
+ abortEarly?: boolean;
14
+ abortEarlyOnEachField?: boolean;
15
+ }
16
+ export interface StrategyAnalysis {
17
+ strategy: ValidationStrategy;
18
+ reason: string;
19
+ canOptimize: boolean;
20
+ hasTransforms: boolean;
21
+ hasArrayFields: boolean;
22
+ fieldCount: number;
23
+ }
24
+ /**
25
+ * Unified validation strategy interface
26
+ */
27
+ export interface IValidationStrategy {
28
+ readonly strategyType: ValidationStrategy;
29
+ validate(value: any, rootData: any, options?: StrategyValidationOptions): ValidationResult;
30
+ parse(value: any, rootData: any, options?: StrategyValidationOptions): ParseResult;
31
+ validateHoisted?(value: any, rootData: any, abortEarlyOnEachField?: boolean): {
32
+ valid: boolean;
33
+ errorIndices?: number[];
34
+ };
35
+ reconstructErrors?(errorIndices: number[], value: any, rootData: any, abortEarlyOnEachField?: boolean): Array<{
36
+ path: string;
37
+ code: string;
38
+ message: string;
39
+ }>;
40
+ }
41
+ /**
42
+ * Fast Separated Strategy
43
+ * Execute in order: Validators → Transforms (optimized)
44
+ */
45
+ export declare function createFastSeparatedStrategy(field: ValidationField, engine?: ValidationEngine): IValidationStrategy;
46
+ /**
47
+ * Definition Order Strategy
48
+ * Execute in definition order (including transforms)
49
+ */
50
+ export declare function createDefinitionOrderStrategy(field: ValidationField, engine?: ValidationEngine): IValidationStrategy;
51
+ /**
52
+ * Array Batch Strategy
53
+ * Batch processing of array elements (optimized)
54
+ */
55
+ export declare function createArrayBatchStrategy(arrayPath: string, elementFields: ValidationField[], engine?: ValidationEngine): IValidationStrategy;
56
+ /**
57
+ * Multi-Field Strategy
58
+ * Integrated processing of multiple fields
59
+ */
60
+ export declare function createMultiFieldStrategy(fields: ValidationField[], engine?: ValidationEngine): IValidationStrategy;
61
+ /**
62
+ * Analyze field definitions to determine optimal strategy
63
+ */
64
+ export declare function analyzeFields(fieldDefinitions: Array<{
65
+ path: string;
66
+ builderFunction: Function;
67
+ }>, plugins: Record<string, any>): StrategyAnalysis;
68
+ /**
69
+ * Create strategy instance
70
+ */
71
+ export declare function createStrategy(analysis: StrategyAnalysis, fieldDefinitions: Array<{
72
+ path: string;
73
+ builderFunction: Function;
74
+ validators?: any[];
75
+ transforms?: any[];
76
+ }>, plugins: Record<string, any>): IValidationStrategy;
77
+ export declare function createOptimalStrategy(fieldDefinitions: Array<{
78
+ path: string;
79
+ builderFunction: Function;
80
+ }>, plugins: Record<string, any>): {
81
+ strategy: IValidationStrategy;
82
+ analysis: StrategyAnalysis;
83
+ };
84
+ export declare function createSingleFieldStrategy(path: string, validators: any[], transforms?: any[]): IValidationStrategy;
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Core Validation Engine
3
+ * Integrated validation execution engine - eliminates duplicate logic
4
+ */
5
+ export interface ValidationError {
6
+ path: string;
7
+ code: string;
8
+ message: string;
9
+ }
10
+ export interface ValidationResult {
11
+ valid: boolean;
12
+ errors: ValidationError[];
13
+ }
14
+ export interface ParseResult extends ValidationResult {
15
+ data?: any;
16
+ }
17
+ export interface ValidationContext {
18
+ originalValue: any;
19
+ currentValue: any;
20
+ allValues: any;
21
+ path: string;
22
+ arrayContext?: import("../../plugin/types").ArrayContext;
23
+ }
24
+ export interface ValidatorFunction {
25
+ check: (value: any, allValues?: any, arrayContext?: import("../../plugin/types").ArrayContext) => boolean;
26
+ code?: string;
27
+ pluginName?: string;
28
+ getErrorMessage?: (value: any, path: string, allValues?: any, arrayContext?: import("../../plugin/types").ArrayContext) => string;
29
+ messageFactory?: (context: any) => string;
30
+ params?: any[];
31
+ metadata?: {
32
+ type?: string;
33
+ category?: string;
34
+ [key: string]: any;
35
+ };
36
+ }
37
+ export interface TransformFunction {
38
+ apply?: (value: any, context?: any) => any;
39
+ transformFn?: (value: any) => any;
40
+ (value: any): any;
41
+ }
42
+ export interface ValidationField {
43
+ path: string;
44
+ validators: ValidatorFunction[];
45
+ transforms: TransformFunction[];
46
+ }
47
+ /**
48
+ * Execute validation for single field
49
+ */
50
+ export declare function validateField(field: ValidationField, value: any, context: ValidationContext, options?: {
51
+ abortEarly?: boolean;
52
+ }): ValidationResult;
53
+ /**
54
+ * Batch validation for multiple fields
55
+ */
56
+ export declare function validateBatch(fields: ValidationField[], values: any, options?: {
57
+ abortEarly?: boolean;
58
+ abortEarlyOnEachField?: boolean;
59
+ }): ValidationResult;
60
+ /**
61
+ * Parse field (validation + transform)
62
+ */
63
+ export declare function parseField(field: ValidationField, value: any, context: ValidationContext, options?: {
64
+ abortEarly?: boolean;
65
+ }): ParseResult;
66
+ /**
67
+ * Batch parse multiple fields
68
+ */
69
+ export declare function parseBatch(fields: ValidationField[], values: any, options?: {
70
+ abortEarly?: boolean;
71
+ abortEarlyOnEachField?: boolean;
72
+ }): ParseResult;
73
+ /**
74
+ * Apply transform (logic duplicated across all files)
75
+ */
76
+ export declare function applyTransforms(transforms: TransformFunction[], value: any, context: ValidationContext): any;
77
+ /**
78
+ * Hoisted validation (for high-speed validation)
79
+ */
80
+ export declare function validateHoisted(field: ValidationField, value: any, allValues: any, abortEarlyOnEachField?: boolean, arrayContext?: import("../../plugin/types").ArrayContext): {
81
+ valid: boolean;
82
+ errorIndices?: number[];
83
+ };
84
+ /**
85
+ * Rebuild errors (for hoisted validation)
86
+ */
87
+ export declare function reconstructErrors(field: ValidationField, errorIndices: number[], value: any, allValues: any, arrayContext?: import("../../plugin/types").ArrayContext): ValidationError[];
88
+ /**
89
+ * ValidationEngine interface for compatibility
90
+ */
91
+ export interface ValidationEngine {
92
+ validateField: typeof validateField;
93
+ validateBatch: typeof validateBatch;
94
+ parseField: typeof parseField;
95
+ parseBatch: typeof parseBatch;
96
+ applyTransforms: typeof applyTransforms;
97
+ validateHoisted: typeof validateHoisted;
98
+ reconstructErrors: typeof reconstructErrors;
99
+ }
100
+ /**
101
+ * 共有エンジンインスタンス取得
102
+ */
103
+ export declare function getValidationEngine(): ValidationEngine;
104
+ /**
105
+ * Create new engine instance (for testing)
106
+ */
107
+ export declare function createValidationEngine(): ValidationEngine;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Execution Strategy Selector (Refactored)
3
+ * Uses integrated StrategyFactory - eliminates duplicate logic
4
+ *
5
+ * Before: 84 lines with strategy analysis duplication
6
+ * After: ~25 lines using unified core systems
7
+ */
8
+ import { StrategyAnalysis } from './core/strategy-factory';
9
+ /**
10
+ * Determine execution strategy for all fields (simplified)
11
+ * Delegates duplicated strategy analysis logic to StrategyFactory
12
+ */
13
+ export declare function selectOptimalStrategies(fieldDefinitions: Array<{
14
+ path: string;
15
+ builderFunction: Function;
16
+ }>, plugins: Record<string, any>): Map<string, StrategyAnalysis>;
17
+ /**
18
+ * Group fields by strategy (simplified)
19
+ */
20
+ export declare function groupByStrategy(strategies: Map<string, StrategyAnalysis>): {
21
+ fastFields: string[];
22
+ slowFields: string[];
23
+ };
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Unified Validator - Integrates meaningless Fast/Slow separation
3
+ *
4
+ * User feedback: validateFast and validateSlow don't need separate function names
5
+ * Since the caller uses the same interface, they should be unified
6
+ *
7
+ * Before: FastValidator + SlowValidator = 519 lines
8
+ * After: UnifiedValidator = ~80 lines (85% reduction)
9
+ */
10
+ interface ValidationResult {
11
+ readonly valid: boolean;
12
+ readonly errors: Array<{
13
+ readonly path: string;
14
+ readonly code: string;
15
+ readonly message: string;
16
+ }>;
17
+ }
18
+ interface ParseResult {
19
+ readonly valid: boolean;
20
+ readonly data?: any;
21
+ readonly errors: Array<{
22
+ readonly path: string;
23
+ readonly code: string;
24
+ readonly message: string;
25
+ }>;
26
+ }
27
+ export interface UnifiedValidator {
28
+ validate(value: any, rootData: any, options?: {
29
+ abortEarlyOnEachField?: boolean;
30
+ }): ValidationResult;
31
+ parse(value: any, rootData: any, options?: {
32
+ abortEarlyOnEachField?: boolean;
33
+ }): ParseResult;
34
+ accessor?: (obj: any) => any;
35
+ }
36
+ type ExecutionStrategy = "definition_order" | "fast_separated";
37
+ /**
38
+ * Create unified validator
39
+ * Fast/Slow differences are internal implementation only, external interface is unified
40
+ */
41
+ export declare function createUnifiedValidator(fieldDef: {
42
+ path: string;
43
+ builderFunction: Function;
44
+ }, plugins: Record<string, any>, strategy?: ExecutionStrategy, accessor?: (obj: any) => any): UnifiedValidator;
45
+ export {};
@@ -0,0 +1 @@
1
+ export { createMockReporter, createMockContext } from '../testUtils';
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @luq-plugin
3
+ * @name arrayContains
4
+ * @category array
5
+ * @description Validates that an array contains at least one item matching the specified schema or value
6
+ * @allowedTypes ["array"]
7
+ * @example
8
+ * ```typescript
9
+ * // Contains specific value
10
+ * const validator = Builder()
11
+ * .use(arrayContainsPlugin)
12
+ * .for<{ tags: string[] }>()
13
+ * .v("tags", (b) => b.array.contains("important"))
14
+ * .build();
15
+ *
16
+ * // Contains matching schema
17
+ * builder.v("items", b => b.array.contains({
18
+ * validator: (value) => typeof value === 'number' && value > 10,
19
+ * message: "Array must contain at least one number greater than 10"
20
+ * }))
21
+ * ```
22
+ * @params
23
+ * - schema: any | { validator: (value: any) => boolean, message?: string } - Value or validation schema
24
+ * @returns Validation function that checks if array contains matching item
25
+ * @since 0.1.0-alpha
26
+ */
27
+ import type { JSONSchema7 } from "json-schema";
28
+ export interface ContainsSchema {
29
+ validator: (value: any) => boolean;
30
+ message?: string;
31
+ }
32
+ export declare const arrayContainsPlugin: import("../..").TypedPlugin<"arrayContains", "contains", (schema: any | ContainsSchema | JSONSchema7) => {
33
+ check: (value: any[]) => boolean;
34
+ code: string;
35
+ getErrorMessage: (value: any[], path: string) => any;
36
+ params: any[];
37
+ }, readonly ["array"], "validator", "standard">;
@@ -0,0 +1,42 @@
1
+ import { ValidationOptions } from "./types";
2
+ /**
3
+ * @luq-plugin
4
+ * @name arrayIncludes
5
+ * @category standard
6
+ * @description Validates that an array contains a specific required element
7
+ * @allowedTypes ["array"]
8
+ * @example
9
+ * ```typescript
10
+ * // Basic usage - check if array contains specific item
11
+ * const validator = Builder()
12
+ * .use(arrayIncludesPlugin)
13
+ * .for<UserData>()
14
+ * .v("roles", (b) => b.array.includes("admin"))
15
+ * .v("permissions", (b) => b.array.includes("read"))
16
+ * .build();
17
+ *
18
+ * // Multiple required items
19
+ * builder.v("features", b => b.array
20
+ * .includes("core")
21
+ * .includes("api")
22
+ * )
23
+ * ```
24
+ * @params
25
+ * - expected: any - The element that must be present in the array
26
+ * - options?: { messageFactory?: (context: MessageContext) => string } - Optional configuration
27
+ * @returns Validation function that returns true if array contains the expected element
28
+ * @customError
29
+ * ```typescript
30
+ * .includes("admin", {
31
+ * messageFactory: ({ path, value, params }) =>
32
+ * `${path} must include "${params.expected}" (current: [${value.join(", ")}])`
33
+ * })
34
+ * ```
35
+ * @since 0.1.0-alpha
36
+ */
37
+ export declare const arrayIncludesPlugin: import("../..").TypedPlugin<"arrayIncludes", "includes", <TElement = any>(element: TElement, options?: ValidationOptions) => {
38
+ check: (value: any) => boolean;
39
+ code: string;
40
+ getErrorMessage: (value: any, path: string) => string;
41
+ params: (ValidationOptions<{}> | TElement)[];
42
+ }, readonly ["array"], "validator", "arrayElement">;
@@ -0,0 +1,43 @@
1
+ import { ValidationOptions, MessageContext } from "./types";
2
+ export interface ArrayMaxLengthContext extends MessageContext {
3
+ max: number;
4
+ actual: number;
5
+ }
6
+ /**
7
+ * @luq-plugin
8
+ * @name arrayMaxLength
9
+ * @category standard
10
+ * @description Validates that an array does not exceed the specified maximum number of elements
11
+ * @allowedTypes ["array"]
12
+ * @example
13
+ * ```typescript
14
+ * // Basic usage - set maximum array length
15
+ * const validator = Builder()
16
+ * .use(arrayMaxLengthPlugin)
17
+ * .for<FormData>()
18
+ * .v("tags", (b) => b.array.maxLength(10))
19
+ * .v("attachments", (b) => b.array.maxLength(5))
20
+ * .build();
21
+ *
22
+ * // Limit file uploads with min and max
23
+ * builder.v("files", b => b.array.minLength(1).maxLength(3))
24
+ * ```
25
+ * @params
26
+ * - maxLength: number - Maximum number of elements allowed
27
+ * - options?: { messageFactory?: (context: MessageContext) => string } - Optional configuration
28
+ * @returns Validation function that returns true if array length does not exceed maximum
29
+ * @customError
30
+ * ```typescript
31
+ * .maxLength(5, {
32
+ * messageFactory: ({ path, value, params }) =>
33
+ * `${path} can have at most ${params.maxLength} items (current: ${value.length})`
34
+ * })
35
+ * ```
36
+ * @since 0.1.0-alpha
37
+ */
38
+ export declare const arrayMaxLengthPlugin: import("../..").TypedPlugin<"arrayMaxLength", "maxLength", (maxLength: number, options?: ValidationOptions<ArrayMaxLengthContext>) => {
39
+ check: (value: any) => boolean;
40
+ code: string;
41
+ getErrorMessage: (value: any, path: string) => string;
42
+ params: (number | ValidationOptions<ArrayMaxLengthContext>)[];
43
+ }, readonly ["array"], "validator", "standard">;
@@ -0,0 +1,43 @@
1
+ import { ValidationOptions, MessageContext } from "./types";
2
+ export interface ArrayMinLengthContext extends MessageContext {
3
+ min: number;
4
+ actual: number;
5
+ }
6
+ /**
7
+ * @luq-plugin
8
+ * @name arrayMinLength
9
+ * @category standard
10
+ * @description Validates that an array has at least the specified minimum number of elements
11
+ * @allowedTypes ["array"]
12
+ * @example
13
+ * ```typescript
14
+ * // Basic usage - set minimum array length
15
+ * const validator = Builder()
16
+ * .use(arrayMinLengthPlugin)
17
+ * .for<FormData>()
18
+ * .v("tags", (b) => b.array.minLength(1))
19
+ * .v("items", (b) => b.array.minLength(3))
20
+ * .build();
21
+ *
22
+ * // Ensure non-empty array
23
+ * builder.v("selectedOptions", b => b.array.required().minLength(1))
24
+ * ```
25
+ * @params
26
+ * - minLength: number - Minimum number of elements required
27
+ * - options?: { messageFactory?: (context: MessageContext) => string } - Optional configuration
28
+ * @returns Validation function that returns true if array length is at least the minimum
29
+ * @customError
30
+ * ```typescript
31
+ * .minLength(3, {
32
+ * messageFactory: ({ path, value, params }) =>
33
+ * `${path} must have at least ${params.minLength} items (current: ${value.length})`
34
+ * })
35
+ * ```
36
+ * @since 0.1.0-alpha
37
+ */
38
+ export declare const arrayMinLengthPlugin: import("../..").TypedPlugin<"arrayMinLength", "minLength", (minLength: number, options?: ValidationOptions<ArrayMinLengthContext>) => {
39
+ check: (value: any) => boolean;
40
+ code: string;
41
+ getErrorMessage: (value: any, path: string) => string;
42
+ params: (number | ValidationOptions<ArrayMinLengthContext>)[];
43
+ }, readonly ["array"], "validator", "standard">;
@@ -0,0 +1,41 @@
1
+ import { ValidationOptions } from "./types";
2
+ /**
3
+ * @luq-plugin
4
+ * @name arrayUnique
5
+ * @category standard
6
+ * @description Validates that all elements in an array are unique (no duplicates)
7
+ * @allowedTypes ["array"]
8
+ * @example
9
+ * ```typescript
10
+ * // Basic usage - ensures all array elements are unique
11
+ * const validator = Builder()
12
+ * .use(arrayUniquePlugin)
13
+ * .for<FormData>()
14
+ * .v("emails", (b) => b.array.unique())
15
+ * .v("userIds", (b) => b.array.required().unique())
16
+ * .build();
17
+ *
18
+ * // For tags or categories
19
+ * builder.v("tags", b => b.array.unique().minLength(1).maxLength(10))
20
+ *
21
+ * // Combining with other array validations
22
+ * builder.v("productCodes", b => b.array.unique().includes("PRIMARY"))
23
+ * ```
24
+ * @params
25
+ * - options?: { messageFactory?: (context: MessageContext) => string } - Optional configuration
26
+ * @returns Validation function that returns true if all array elements are unique
27
+ * @customError
28
+ * ```typescript
29
+ * .unique({
30
+ * messageFactory: ({ path, value }) =>
31
+ * `${path} contains duplicate values`
32
+ * })
33
+ * ```
34
+ * @since 0.1.0-alpha
35
+ */
36
+ export declare const arrayUniquePlugin: import("../..").TypedPlugin<"arrayUnique", "unique", (options?: ValidationOptions) => {
37
+ check: (value: any) => boolean;
38
+ code: string;
39
+ getErrorMessage: (value: any, path: string) => string;
40
+ params: ValidationOptions<{}>[];
41
+ }, readonly ["array"], "validator", "standard">;
@@ -0,0 +1,41 @@
1
+ import { ValidationOptions } from "./types";
2
+ /**
3
+ * @luq-plugin
4
+ * @name booleanFalsy
5
+ * @category standard
6
+ * @description Validates that a boolean value is exactly false
7
+ * @allowedTypes ["boolean"]
8
+ * @example
9
+ * ```typescript
10
+ * // Basic usage - ensures value is exactly false
11
+ * const validator = Builder()
12
+ * .use(booleanFalsyPlugin)
13
+ * .for<Settings>()
14
+ * .v("isActive", (b) => b.boolean.falsy())
15
+ * .v("debugMode", (b) => b.boolean.required().falsy())
16
+ * .build();
17
+ *
18
+ * // Privacy settings
19
+ * builder.v("shareData", b => b.boolean.falsy())
20
+ *
21
+ * // Security flags
22
+ * builder.v("allowExternalAccess", b => b.boolean.required().falsy())
23
+ * ```
24
+ * @params
25
+ * - options?: { messageFactory?: (context: MessageContext) => string } - Optional configuration
26
+ * @returns Validation function that returns true if value is exactly false
27
+ * @customError
28
+ * ```typescript
29
+ * .falsy({
30
+ * messageFactory: ({ path, value }) =>
31
+ * `${path} must be set to false (current: ${value})`
32
+ * })
33
+ * ```
34
+ * @since 0.1.0-alpha
35
+ */
36
+ export declare const booleanFalsyPlugin: import("../..").TypedPlugin<"booleanFalsy", "falsy", (options?: ValidationOptions) => {
37
+ check: (value: any) => boolean;
38
+ code: string;
39
+ getErrorMessage: (value: any, path: string) => string;
40
+ params: ValidationOptions<{}>[];
41
+ }, readonly ["boolean"], "validator", "standard">;
@@ -0,0 +1,38 @@
1
+ import { ValidationOptions } from "./types";
2
+ /**
3
+ * @luq-plugin
4
+ * @name booleanTruthy
5
+ * @category standard
6
+ * @description Validates that a boolean value is exactly true
7
+ * @allowedTypes ["boolean"]
8
+ * @example
9
+ * ```typescript
10
+ * // Basic usage - ensure value is exactly true
11
+ * const validator = Builder()
12
+ * .use(booleanTruthyPlugin)
13
+ * .for<FormData>()
14
+ * .v("isActive", (b) => b.boolean.truthy())
15
+ * .v("termsAccepted", (b) => b.boolean.required().truthy())
16
+ * .build();
17
+ *
18
+ * // For consent checkboxes
19
+ * builder.v("agreeToTerms", b => b.boolean.required().truthy())
20
+ * ```
21
+ * @params
22
+ * - options?: { messageFactory?: (context: MessageContext) => string } - Optional configuration
23
+ * @returns Validation function that returns true only if value is exactly true
24
+ * @customError
25
+ * ```typescript
26
+ * .truthy({
27
+ * messageFactory: ({ path }) =>
28
+ * `${path} must be checked/accepted`
29
+ * })
30
+ * ```
31
+ * @since 0.1.0-alpha
32
+ */
33
+ export declare const booleanTruthyPlugin: import("../..").TypedPlugin<"booleanTruthy", "truthy", (options?: ValidationOptions) => {
34
+ check: (value: any) => boolean;
35
+ code: string;
36
+ getErrorMessage: (value: any, path: string) => string;
37
+ params: ValidationOptions<{}>[];
38
+ }, readonly ["boolean"], "validator", "standard">;
@@ -0,0 +1,58 @@
1
+ import { ValidationOptions } from "./types";
2
+ type CompareFn = (value: any, targetValue: any) => boolean;
3
+ interface CompareFieldOptions extends ValidationOptions {
4
+ compareFn?: CompareFn;
5
+ }
6
+ /**
7
+ * @luq-plugin
8
+ * @name compareField
9
+ * @category standard
10
+ * @description Validates a field's value by comparing it with another field's value using a custom comparison function
11
+ * @allowedTypes ["string", "number", "boolean", "date", "object", "array", "null", "undefined"]
12
+ * @example
13
+ * ```typescript
14
+ * // Default usage - strict equality
15
+ * const validator = Builder()
16
+ * .use(compareFieldPlugin)
17
+ * .for<SignupForm>()
18
+ * .v("password", (b) => b.string.required().min(8))
19
+ * .v("confirmPassword", (b) => b.string.required().compareField("password"))
20
+ * .build();
21
+ *
22
+ * // Custom comparison - date before
23
+ * builder.v("endDate", (b) => b.string.datetime().compareField("startDate", {
24
+ * compareFn: (endDate, startDate) => new Date(endDate) > new Date(startDate),
25
+ * messageFactory: () => "End date must be after start date"
26
+ * }))
27
+ *
28
+ * // Number comparison
29
+ * builder.v("maxValue", (b) => b.number.compareField("minValue", {
30
+ * compareFn: (max, min) => max >= min,
31
+ * messageFactory: () => "Max value must be greater than or equal to min value"
32
+ * }))
33
+ * ```
34
+ * @params
35
+ * - fieldPath: string - Path to the field to compare against (supports dot notation)
36
+ * - options?: { compareFn?: (value, targetValue) => boolean, messageFactory?: (context) => string } - Optional configuration
37
+ * @returns Validation function that returns true if comparison passes
38
+ * @customError
39
+ * ```typescript
40
+ * .compareField("startDate", {
41
+ * compareFn: (end, start) => new Date(end) > new Date(start),
42
+ * messageFactory: ({ path, value, params }) =>
43
+ * `${path} must be after ${params.fieldPath}`
44
+ * })
45
+ * ```
46
+ * @since 0.1.0-alpha
47
+ */
48
+ export declare const compareFieldPlugin: import("../..").TypedPlugin<"compareField", "compareField", (fieldPath: string, options?: CompareFieldOptions) => {
49
+ check: (value: any, allValues?: any) => boolean;
50
+ code: string;
51
+ getErrorMessage: (value: any, path: string, allValues?: any) => string;
52
+ params: (string | CompareFieldOptions)[];
53
+ fieldReference: {
54
+ fieldPath: string;
55
+ compareFn: CompareFn;
56
+ };
57
+ }, readonly ["string", "number", "boolean", "date", "object", "array", "tuple", "union"], "validator", "fieldReference">;
58
+ export {};
@@ -0,0 +1,24 @@
1
+ import { ValidationOptions } from "./types";
2
+ import { JSONSchema7 } from "json-schema";
3
+ export interface ConditionalSchemaOptions extends ValidationOptions {
4
+ ifSchema: JSONSchema7;
5
+ thenSchema?: JSONSchema7;
6
+ elseSchema?: JSONSchema7;
7
+ validator?: (value: any, schema: JSONSchema7) => boolean;
8
+ }
9
+ /**
10
+ * Conditional Schema Plugin (if/then/else)
11
+ *
12
+ * Handles JSON Schema Draft-07 conditional validation
13
+ * @luq-plugin
14
+ * @name conditionalSchema
15
+ * @category advanced
16
+ * @description Validates based on if/then/else conditions
17
+ * @allowedTypes ["object"]
18
+ */
19
+ export declare const conditionalSchemaPlugin: import("../..").TypedPlugin<"conditionalSchema", "conditionalSchema", (options: ConditionalSchemaOptions) => {
20
+ check: (value: any) => boolean;
21
+ code: string;
22
+ getErrorMessage: (value: any, path: string) => string;
23
+ params: ConditionalSchemaOptions[];
24
+ }, readonly ["object"], "validator", "standard">;