reliant-type 1.0.0

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 (345) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1305 -0
  3. package/dist/cjs/constants/SECURITY_CONSTANTS.js +49 -0
  4. package/dist/cjs/constants/SECURITY_CONSTANTS.js.map +1 -0
  5. package/dist/cjs/constants/VALIDATION_CONSTANTS.js +103 -0
  6. package/dist/cjs/constants/VALIDATION_CONSTANTS.js.map +1 -0
  7. package/dist/cjs/core/schema/extensions/SmartInference.js +200 -0
  8. package/dist/cjs/core/schema/extensions/SmartInference.js.map +1 -0
  9. package/dist/cjs/core/schema/extensions/components/AutoDocumentation/Docs.js +100 -0
  10. package/dist/cjs/core/schema/extensions/components/AutoDocumentation/Docs.js.map +1 -0
  11. package/dist/cjs/core/schema/extensions/components/AutoDocumentation/DocumentationGenerator.js +192 -0
  12. package/dist/cjs/core/schema/extensions/components/AutoDocumentation/DocumentationGenerator.js.map +1 -0
  13. package/dist/cjs/core/schema/extensions/components/AutoDocumentation/InteractiveDocumentationGenerator.js +174 -0
  14. package/dist/cjs/core/schema/extensions/components/AutoDocumentation/InteractiveDocumentationGenerator.js.map +1 -0
  15. package/dist/cjs/core/schema/extensions/components/AutoDocumentation/SchemaAnalyzer.js +54 -0
  16. package/dist/cjs/core/schema/extensions/components/AutoDocumentation/SchemaAnalyzer.js.map +1 -0
  17. package/dist/cjs/core/schema/extensions/components/AutoDocumentation/TypeScriptGenerator.js +50 -0
  18. package/dist/cjs/core/schema/extensions/components/AutoDocumentation/TypeScriptGenerator.js.map +1 -0
  19. package/dist/cjs/core/schema/extensions/components/AutoDocumentation/index.js +15 -0
  20. package/dist/cjs/core/schema/extensions/components/AutoDocumentation/index.js.map +1 -0
  21. package/dist/cjs/core/schema/extensions/components/ConditionalValidation/ConditionalBuilder.js +70 -0
  22. package/dist/cjs/core/schema/extensions/components/ConditionalValidation/ConditionalBuilder.js.map +1 -0
  23. package/dist/cjs/core/schema/extensions/components/ConditionalValidation/ConditionalElse.js +40 -0
  24. package/dist/cjs/core/schema/extensions/components/ConditionalValidation/ConditionalElse.js.map +1 -0
  25. package/dist/cjs/core/schema/extensions/components/ConditionalValidation/ConditionalThen.js +19 -0
  26. package/dist/cjs/core/schema/extensions/components/ConditionalValidation/ConditionalThen.js.map +1 -0
  27. package/dist/cjs/core/schema/extensions/components/ConditionalValidation/MultiConditionalBuilder.js +20 -0
  28. package/dist/cjs/core/schema/extensions/components/ConditionalValidation/MultiConditionalBuilder.js.map +1 -0
  29. package/dist/cjs/core/schema/extensions/components/ConditionalValidation/MultiConditionalThen.js +49 -0
  30. package/dist/cjs/core/schema/extensions/components/ConditionalValidation/MultiConditionalThen.js.map +1 -0
  31. package/dist/cjs/core/schema/extensions/components/ConditionalValidation/index.js +98 -0
  32. package/dist/cjs/core/schema/extensions/components/ConditionalValidation/index.js.map +1 -0
  33. package/dist/cjs/core/schema/extensions/components/RealtimeValidation/FormValidator.js +85 -0
  34. package/dist/cjs/core/schema/extensions/components/RealtimeValidation/FormValidator.js.map +1 -0
  35. package/dist/cjs/core/schema/extensions/components/RealtimeValidation/LiveValidator.js +133 -0
  36. package/dist/cjs/core/schema/extensions/components/RealtimeValidation/LiveValidator.js.map +1 -0
  37. package/dist/cjs/core/schema/extensions/components/RealtimeValidation/StreamValidator.js +351 -0
  38. package/dist/cjs/core/schema/extensions/components/RealtimeValidation/StreamValidator.js.map +1 -0
  39. package/dist/cjs/core/schema/extensions/components/RealtimeValidation/index.js +109 -0
  40. package/dist/cjs/core/schema/extensions/components/RealtimeValidation/index.js.map +1 -0
  41. package/dist/cjs/core/schema/extensions/index.js +61 -0
  42. package/dist/cjs/core/schema/extensions/index.js.map +1 -0
  43. package/dist/cjs/core/schema/extensions/mods/index.js +51 -0
  44. package/dist/cjs/core/schema/extensions/mods/index.js.map +1 -0
  45. package/dist/cjs/core/schema/extensions/mods/openapi-converter.js +227 -0
  46. package/dist/cjs/core/schema/extensions/mods/openapi-converter.js.map +1 -0
  47. package/dist/cjs/core/schema/extensions/mods/typescript-generator.js +287 -0
  48. package/dist/cjs/core/schema/extensions/mods/typescript-generator.js.map +1 -0
  49. package/dist/cjs/core/schema/extensions/mods/validation-engine.js +224 -0
  50. package/dist/cjs/core/schema/extensions/mods/validation-engine.js.map +1 -0
  51. package/dist/cjs/core/schema/mode/interfaces/Interface.js +277 -0
  52. package/dist/cjs/core/schema/mode/interfaces/Interface.js.map +1 -0
  53. package/dist/cjs/core/schema/mode/interfaces/InterfaceSchema.js +1431 -0
  54. package/dist/cjs/core/schema/mode/interfaces/InterfaceSchema.js.map +1 -0
  55. package/dist/cjs/core/schema/mode/interfaces/conditional/evaluator/ConditionalEvaluator.js +520 -0
  56. package/dist/cjs/core/schema/mode/interfaces/conditional/evaluator/ConditionalEvaluator.js.map +1 -0
  57. package/dist/cjs/core/schema/mode/interfaces/conditional/parser/ConditionalAST.js +624 -0
  58. package/dist/cjs/core/schema/mode/interfaces/conditional/parser/ConditionalAST.js.map +1 -0
  59. package/dist/cjs/core/schema/mode/interfaces/conditional/parser/ConditionalLexer.js +811 -0
  60. package/dist/cjs/core/schema/mode/interfaces/conditional/parser/ConditionalLexer.js.map +1 -0
  61. package/dist/cjs/core/schema/mode/interfaces/conditional/parser/ConditionalParser.js +599 -0
  62. package/dist/cjs/core/schema/mode/interfaces/conditional/parser/ConditionalParser.js.map +1 -0
  63. package/dist/cjs/core/schema/mode/interfaces/conditional/types/ConditionalTypes.js +89 -0
  64. package/dist/cjs/core/schema/mode/interfaces/conditional/types/ConditionalTypes.js.map +1 -0
  65. package/dist/cjs/core/schema/mode/interfaces/errors/ErrorHandler.js +356 -0
  66. package/dist/cjs/core/schema/mode/interfaces/errors/ErrorHandler.js.map +1 -0
  67. package/dist/cjs/core/schema/mode/interfaces/errors/types/errors.type.js +80 -0
  68. package/dist/cjs/core/schema/mode/interfaces/errors/types/errors.type.js.map +1 -0
  69. package/dist/cjs/core/schema/mode/interfaces/precompilation/FieldPrecompilers.js +778 -0
  70. package/dist/cjs/core/schema/mode/interfaces/precompilation/FieldPrecompilers.js.map +1 -0
  71. package/dist/cjs/core/schema/mode/interfaces/precompilation/SchemaPrecompiler.js +523 -0
  72. package/dist/cjs/core/schema/mode/interfaces/precompilation/SchemaPrecompiler.js.map +1 -0
  73. package/dist/cjs/core/schema/mode/interfaces/typescript/ConditionalTypes.js +681 -0
  74. package/dist/cjs/core/schema/mode/interfaces/typescript/ConditionalTypes.js.map +1 -0
  75. package/dist/cjs/core/schema/mode/interfaces/typescript/IDESupport.js +430 -0
  76. package/dist/cjs/core/schema/mode/interfaces/typescript/IDESupport.js.map +1 -0
  77. package/dist/cjs/core/schema/mode/interfaces/typescript/TypeInference.js +225 -0
  78. package/dist/cjs/core/schema/mode/interfaces/typescript/TypeInference.js.map +1 -0
  79. package/dist/cjs/core/schema/mode/interfaces/typescript/index.js +44 -0
  80. package/dist/cjs/core/schema/mode/interfaces/typescript/index.js.map +1 -0
  81. package/dist/cjs/core/schema/mode/interfaces/validators/ConstraintParser.js +1134 -0
  82. package/dist/cjs/core/schema/mode/interfaces/validators/ConstraintParser.js.map +1 -0
  83. package/dist/cjs/core/schema/mode/interfaces/validators/TypeGuards.js +256 -0
  84. package/dist/cjs/core/schema/mode/interfaces/validators/TypeGuards.js.map +1 -0
  85. package/dist/cjs/core/schema/mode/interfaces/validators/TypeValidators.js +429 -0
  86. package/dist/cjs/core/schema/mode/interfaces/validators/TypeValidators.js.map +1 -0
  87. package/dist/cjs/core/schema/mode/interfaces/validators/UnionCache.js +404 -0
  88. package/dist/cjs/core/schema/mode/interfaces/validators/UnionCache.js.map +1 -0
  89. package/dist/cjs/core/schema/mode/interfaces/validators/ValidationHelpers.js +851 -0
  90. package/dist/cjs/core/schema/mode/interfaces/validators/ValidationHelpers.js.map +1 -0
  91. package/dist/cjs/core/schema/mode/interfaces/validators/mods/passValidator.js +262 -0
  92. package/dist/cjs/core/schema/mode/interfaces/validators/mods/passValidator.js.map +1 -0
  93. package/dist/cjs/core/schema/mode/interfaces/validators/mods/securityValidator.js +887 -0
  94. package/dist/cjs/core/schema/mode/interfaces/validators/mods/securityValidator.js.map +1 -0
  95. package/dist/cjs/core/schema/mode/interfaces/validators/mods/urlValidation.js +191 -0
  96. package/dist/cjs/core/schema/mode/interfaces/validators/mods/urlValidation.js.map +1 -0
  97. package/dist/cjs/core/schema/optimization/ObjectValidationCache.js +462 -0
  98. package/dist/cjs/core/schema/optimization/ObjectValidationCache.js.map +1 -0
  99. package/dist/cjs/core/schema/optimization/PerformanceMonitor.js +773 -0
  100. package/dist/cjs/core/schema/optimization/PerformanceMonitor.js.map +1 -0
  101. package/dist/cjs/core/schema/optimization/SchemaCompiler.js +600 -0
  102. package/dist/cjs/core/schema/optimization/SchemaCompiler.js.map +1 -0
  103. package/dist/cjs/core/types/ValidatorTypes.js +70 -0
  104. package/dist/cjs/core/types/ValidatorTypes.js.map +1 -0
  105. package/dist/cjs/core/types/parser.type.js +12 -0
  106. package/dist/cjs/core/types/parser.type.js.map +1 -0
  107. package/dist/cjs/core/utils/Make.js +61 -0
  108. package/dist/cjs/core/utils/Make.js.map +1 -0
  109. package/dist/cjs/core/utils/Mod.js +1033 -0
  110. package/dist/cjs/core/utils/Mod.js.map +1 -0
  111. package/dist/cjs/core/utils/UrlArgs.js +102 -0
  112. package/dist/cjs/core/utils/UrlArgs.js.map +1 -0
  113. package/dist/cjs/core/utils/arrayToEnum.js +18 -0
  114. package/dist/cjs/core/utils/arrayToEnum.js.map +1 -0
  115. package/dist/cjs/core/utils/createUrlArgsEnumFArray.js +13 -0
  116. package/dist/cjs/core/utils/createUrlArgsEnumFArray.js.map +1 -0
  117. package/dist/cjs/core/utils/securityHelpers.js +215 -0
  118. package/dist/cjs/core/utils/securityHelpers.js.map +1 -0
  119. package/dist/cjs/core/utils/securityValidatorHelpers.js +65 -0
  120. package/dist/cjs/core/utils/securityValidatorHelpers.js.map +1 -0
  121. package/dist/cjs/index.js +31 -0
  122. package/dist/cjs/index.js.map +1 -0
  123. package/dist/cjs/package.json +3 -0
  124. package/dist/esm/constants/SECURITY_CONSTANTS.js +47 -0
  125. package/dist/esm/constants/SECURITY_CONSTANTS.js.map +1 -0
  126. package/dist/esm/constants/VALIDATION_CONSTANTS.js +98 -0
  127. package/dist/esm/constants/VALIDATION_CONSTANTS.js.map +1 -0
  128. package/dist/esm/core/schema/extensions/SmartInference.js +197 -0
  129. package/dist/esm/core/schema/extensions/SmartInference.js.map +1 -0
  130. package/dist/esm/core/schema/extensions/components/AutoDocumentation/Docs.js +98 -0
  131. package/dist/esm/core/schema/extensions/components/AutoDocumentation/Docs.js.map +1 -0
  132. package/dist/esm/core/schema/extensions/components/AutoDocumentation/DocumentationGenerator.js +190 -0
  133. package/dist/esm/core/schema/extensions/components/AutoDocumentation/DocumentationGenerator.js.map +1 -0
  134. package/dist/esm/core/schema/extensions/components/AutoDocumentation/InteractiveDocumentationGenerator.js +172 -0
  135. package/dist/esm/core/schema/extensions/components/AutoDocumentation/InteractiveDocumentationGenerator.js.map +1 -0
  136. package/dist/esm/core/schema/extensions/components/AutoDocumentation/SchemaAnalyzer.js +52 -0
  137. package/dist/esm/core/schema/extensions/components/AutoDocumentation/SchemaAnalyzer.js.map +1 -0
  138. package/dist/esm/core/schema/extensions/components/AutoDocumentation/TypeScriptGenerator.js +48 -0
  139. package/dist/esm/core/schema/extensions/components/AutoDocumentation/TypeScriptGenerator.js.map +1 -0
  140. package/dist/esm/core/schema/extensions/components/AutoDocumentation/index.js +12 -0
  141. package/dist/esm/core/schema/extensions/components/AutoDocumentation/index.js.map +1 -0
  142. package/dist/esm/core/schema/extensions/components/ConditionalValidation/ConditionalBuilder.js +68 -0
  143. package/dist/esm/core/schema/extensions/components/ConditionalValidation/ConditionalBuilder.js.map +1 -0
  144. package/dist/esm/core/schema/extensions/components/ConditionalValidation/ConditionalElse.js +38 -0
  145. package/dist/esm/core/schema/extensions/components/ConditionalValidation/ConditionalElse.js.map +1 -0
  146. package/dist/esm/core/schema/extensions/components/ConditionalValidation/ConditionalThen.js +17 -0
  147. package/dist/esm/core/schema/extensions/components/ConditionalValidation/ConditionalThen.js.map +1 -0
  148. package/dist/esm/core/schema/extensions/components/ConditionalValidation/MultiConditionalBuilder.js +18 -0
  149. package/dist/esm/core/schema/extensions/components/ConditionalValidation/MultiConditionalBuilder.js.map +1 -0
  150. package/dist/esm/core/schema/extensions/components/ConditionalValidation/MultiConditionalThen.js +45 -0
  151. package/dist/esm/core/schema/extensions/components/ConditionalValidation/MultiConditionalThen.js.map +1 -0
  152. package/dist/esm/core/schema/extensions/components/ConditionalValidation/index.js +92 -0
  153. package/dist/esm/core/schema/extensions/components/ConditionalValidation/index.js.map +1 -0
  154. package/dist/esm/core/schema/extensions/components/RealtimeValidation/FormValidator.js +83 -0
  155. package/dist/esm/core/schema/extensions/components/RealtimeValidation/FormValidator.js.map +1 -0
  156. package/dist/esm/core/schema/extensions/components/RealtimeValidation/LiveValidator.js +131 -0
  157. package/dist/esm/core/schema/extensions/components/RealtimeValidation/LiveValidator.js.map +1 -0
  158. package/dist/esm/core/schema/extensions/components/RealtimeValidation/StreamValidator.js +349 -0
  159. package/dist/esm/core/schema/extensions/components/RealtimeValidation/StreamValidator.js.map +1 -0
  160. package/dist/esm/core/schema/extensions/components/RealtimeValidation/index.js +103 -0
  161. package/dist/esm/core/schema/extensions/components/RealtimeValidation/index.js.map +1 -0
  162. package/dist/esm/core/schema/extensions/index.js +53 -0
  163. package/dist/esm/core/schema/extensions/index.js.map +1 -0
  164. package/dist/esm/core/schema/extensions/mods/index.js +47 -0
  165. package/dist/esm/core/schema/extensions/mods/index.js.map +1 -0
  166. package/dist/esm/core/schema/extensions/mods/openapi-converter.js +225 -0
  167. package/dist/esm/core/schema/extensions/mods/openapi-converter.js.map +1 -0
  168. package/dist/esm/core/schema/extensions/mods/typescript-generator.js +284 -0
  169. package/dist/esm/core/schema/extensions/mods/typescript-generator.js.map +1 -0
  170. package/dist/esm/core/schema/extensions/mods/validation-engine.js +222 -0
  171. package/dist/esm/core/schema/extensions/mods/validation-engine.js.map +1 -0
  172. package/dist/esm/core/schema/mode/interfaces/Interface.js +269 -0
  173. package/dist/esm/core/schema/mode/interfaces/Interface.js.map +1 -0
  174. package/dist/esm/core/schema/mode/interfaces/InterfaceSchema.js +1429 -0
  175. package/dist/esm/core/schema/mode/interfaces/InterfaceSchema.js.map +1 -0
  176. package/dist/esm/core/schema/mode/interfaces/conditional/evaluator/ConditionalEvaluator.js +518 -0
  177. package/dist/esm/core/schema/mode/interfaces/conditional/evaluator/ConditionalEvaluator.js.map +1 -0
  178. package/dist/esm/core/schema/mode/interfaces/conditional/parser/ConditionalAST.js +620 -0
  179. package/dist/esm/core/schema/mode/interfaces/conditional/parser/ConditionalAST.js.map +1 -0
  180. package/dist/esm/core/schema/mode/interfaces/conditional/parser/ConditionalLexer.js +809 -0
  181. package/dist/esm/core/schema/mode/interfaces/conditional/parser/ConditionalLexer.js.map +1 -0
  182. package/dist/esm/core/schema/mode/interfaces/conditional/parser/ConditionalParser.js +597 -0
  183. package/dist/esm/core/schema/mode/interfaces/conditional/parser/ConditionalParser.js.map +1 -0
  184. package/dist/esm/core/schema/mode/interfaces/conditional/types/ConditionalTypes.js +89 -0
  185. package/dist/esm/core/schema/mode/interfaces/conditional/types/ConditionalTypes.js.map +1 -0
  186. package/dist/esm/core/schema/mode/interfaces/errors/ErrorHandler.js +354 -0
  187. package/dist/esm/core/schema/mode/interfaces/errors/ErrorHandler.js.map +1 -0
  188. package/dist/esm/core/schema/mode/interfaces/errors/types/errors.type.js +80 -0
  189. package/dist/esm/core/schema/mode/interfaces/errors/types/errors.type.js.map +1 -0
  190. package/dist/esm/core/schema/mode/interfaces/precompilation/FieldPrecompilers.js +776 -0
  191. package/dist/esm/core/schema/mode/interfaces/precompilation/FieldPrecompilers.js.map +1 -0
  192. package/dist/esm/core/schema/mode/interfaces/precompilation/SchemaPrecompiler.js +521 -0
  193. package/dist/esm/core/schema/mode/interfaces/precompilation/SchemaPrecompiler.js.map +1 -0
  194. package/dist/esm/core/schema/mode/interfaces/typescript/ConditionalTypes.js +681 -0
  195. package/dist/esm/core/schema/mode/interfaces/typescript/ConditionalTypes.js.map +1 -0
  196. package/dist/esm/core/schema/mode/interfaces/typescript/IDESupport.js +428 -0
  197. package/dist/esm/core/schema/mode/interfaces/typescript/IDESupport.js.map +1 -0
  198. package/dist/esm/core/schema/mode/interfaces/typescript/TypeInference.js +223 -0
  199. package/dist/esm/core/schema/mode/interfaces/typescript/TypeInference.js.map +1 -0
  200. package/dist/esm/core/schema/mode/interfaces/typescript/index.js +35 -0
  201. package/dist/esm/core/schema/mode/interfaces/typescript/index.js.map +1 -0
  202. package/dist/esm/core/schema/mode/interfaces/validators/ConstraintParser.js +1132 -0
  203. package/dist/esm/core/schema/mode/interfaces/validators/ConstraintParser.js.map +1 -0
  204. package/dist/esm/core/schema/mode/interfaces/validators/TypeGuards.js +254 -0
  205. package/dist/esm/core/schema/mode/interfaces/validators/TypeGuards.js.map +1 -0
  206. package/dist/esm/core/schema/mode/interfaces/validators/TypeValidators.js +427 -0
  207. package/dist/esm/core/schema/mode/interfaces/validators/TypeValidators.js.map +1 -0
  208. package/dist/esm/core/schema/mode/interfaces/validators/UnionCache.js +400 -0
  209. package/dist/esm/core/schema/mode/interfaces/validators/UnionCache.js.map +1 -0
  210. package/dist/esm/core/schema/mode/interfaces/validators/ValidationHelpers.js +849 -0
  211. package/dist/esm/core/schema/mode/interfaces/validators/ValidationHelpers.js.map +1 -0
  212. package/dist/esm/core/schema/mode/interfaces/validators/mods/passValidator.js +260 -0
  213. package/dist/esm/core/schema/mode/interfaces/validators/mods/passValidator.js.map +1 -0
  214. package/dist/esm/core/schema/mode/interfaces/validators/mods/securityValidator.js +881 -0
  215. package/dist/esm/core/schema/mode/interfaces/validators/mods/securityValidator.js.map +1 -0
  216. package/dist/esm/core/schema/mode/interfaces/validators/mods/urlValidation.js +189 -0
  217. package/dist/esm/core/schema/mode/interfaces/validators/mods/urlValidation.js.map +1 -0
  218. package/dist/esm/core/schema/optimization/ObjectValidationCache.js +460 -0
  219. package/dist/esm/core/schema/optimization/ObjectValidationCache.js.map +1 -0
  220. package/dist/esm/core/schema/optimization/PerformanceMonitor.js +771 -0
  221. package/dist/esm/core/schema/optimization/PerformanceMonitor.js.map +1 -0
  222. package/dist/esm/core/schema/optimization/SchemaCompiler.js +598 -0
  223. package/dist/esm/core/schema/optimization/SchemaCompiler.js.map +1 -0
  224. package/dist/esm/core/types/ValidatorTypes.js +65 -0
  225. package/dist/esm/core/types/ValidatorTypes.js.map +1 -0
  226. package/dist/esm/core/types/parser.type.js +12 -0
  227. package/dist/esm/core/types/parser.type.js.map +1 -0
  228. package/dist/esm/core/utils/Make.js +59 -0
  229. package/dist/esm/core/utils/Make.js.map +1 -0
  230. package/dist/esm/core/utils/Mod.js +1031 -0
  231. package/dist/esm/core/utils/Mod.js.map +1 -0
  232. package/dist/esm/core/utils/UrlArgs.js +98 -0
  233. package/dist/esm/core/utils/UrlArgs.js.map +1 -0
  234. package/dist/esm/core/utils/arrayToEnum.js +16 -0
  235. package/dist/esm/core/utils/arrayToEnum.js.map +1 -0
  236. package/dist/esm/core/utils/createUrlArgsEnumFArray.js +11 -0
  237. package/dist/esm/core/utils/createUrlArgsEnumFArray.js.map +1 -0
  238. package/dist/esm/core/utils/securityHelpers.js +207 -0
  239. package/dist/esm/core/utils/securityHelpers.js.map +1 -0
  240. package/dist/esm/core/utils/securityValidatorHelpers.js +62 -0
  241. package/dist/esm/core/utils/securityValidatorHelpers.js.map +1 -0
  242. package/dist/esm/index.js +12 -0
  243. package/dist/esm/index.js.map +1 -0
  244. package/dist/esm/package.json +3 -0
  245. package/dist/schema.d.ts +2595 -0
  246. package/docs/ALL_TYPES.md +120 -0
  247. package/docs/API-STABILITY.md +336 -0
  248. package/docs/CONDITIONAL-VALIDATION.md +637 -0
  249. package/docs/EXAMPLES.md +876 -0
  250. package/docs/FIELD-TYPES.md +829 -0
  251. package/docs/GETTING-STARTED.md +394 -0
  252. package/docs/LIVE-UTILITY.md +1137 -0
  253. package/docs/QUICK-REFERENCE.md +346 -0
  254. package/docs/README.md +205 -0
  255. package/docs/VSCODE-EXTENSION.md +458 -0
  256. package/package.json +219 -0
  257. package/src/bench/BENCHMARK-RESULTS.md +211 -0
  258. package/src/bench/benchmark-results.json +148 -0
  259. package/src/bench/performance-comparison.ts +218 -0
  260. package/src/bench/precompilation-benchmark.ts +218 -0
  261. package/src/constants/SECURITY_CONSTANTS.ts +44 -0
  262. package/src/constants/VALIDATION_CONSTANTS.ts +176 -0
  263. package/src/core/README.md +395 -0
  264. package/src/core/compiler/SchemaTransformer.ts +279 -0
  265. package/src/core/compiler/TypeAnalyzer.ts +378 -0
  266. package/src/core/compiler/TypeScriptCompilerIntegration.ts +220 -0
  267. package/src/core/compiler/TypeToSchemaConverter.ts +288 -0
  268. package/src/core/index.ts +70 -0
  269. package/src/core/schema/extensions/AutoDocumentation.ts +572 -0
  270. package/src/core/schema/extensions/ConditionalValidation.ts +330 -0
  271. package/src/core/schema/extensions/README.md +171 -0
  272. package/src/core/schema/extensions/RealtimeValidation.ts +656 -0
  273. package/src/core/schema/extensions/SmartInference.ts +224 -0
  274. package/src/core/schema/extensions/components/AutoDocumentation/Docs.ts +98 -0
  275. package/src/core/schema/extensions/components/AutoDocumentation/DocumentationGenerator.ts +201 -0
  276. package/src/core/schema/extensions/components/AutoDocumentation/InteractiveDocumentationGenerator.ts +176 -0
  277. package/src/core/schema/extensions/components/AutoDocumentation/OpenAPIGenerator.ts +175 -0
  278. package/src/core/schema/extensions/components/AutoDocumentation/SchemaAnalyzer.ts +49 -0
  279. package/src/core/schema/extensions/components/AutoDocumentation/TypeScriptGenerator.ts +54 -0
  280. package/src/core/schema/extensions/components/AutoDocumentation/index.ts +17 -0
  281. package/src/core/schema/extensions/components/ConditionalValidation/ConditionalBuilder.ts +101 -0
  282. package/src/core/schema/extensions/components/ConditionalValidation/ConditionalElse.ts +65 -0
  283. package/src/core/schema/extensions/components/ConditionalValidation/ConditionalThen.ts +33 -0
  284. package/src/core/schema/extensions/components/ConditionalValidation/Extend.ts +75 -0
  285. package/src/core/schema/extensions/components/ConditionalValidation/MultiConditionalBuilder.ts +16 -0
  286. package/src/core/schema/extensions/components/ConditionalValidation/MultiConditionalThen.ts +50 -0
  287. package/src/core/schema/extensions/components/ConditionalValidation/index.ts +104 -0
  288. package/src/core/schema/extensions/components/RealtimeValidation/FormValidator.ts +88 -0
  289. package/src/core/schema/extensions/components/RealtimeValidation/LiveValidator.ts +171 -0
  290. package/src/core/schema/extensions/components/RealtimeValidation/StreamValidator.ts +397 -0
  291. package/src/core/schema/extensions/components/RealtimeValidation/index.ts +114 -0
  292. package/src/core/schema/extensions/index.ts +76 -0
  293. package/src/core/schema/extensions/mods/index.ts +131 -0
  294. package/src/core/schema/extensions/mods/openapi-converter.ts +338 -0
  295. package/src/core/schema/extensions/mods/typescript-generator.ts +379 -0
  296. package/src/core/schema/extensions/mods/validation-engine.ts +295 -0
  297. package/src/core/schema/mode/interfaces/Interface.ts +364 -0
  298. package/src/core/schema/mode/interfaces/InterfaceSchema.ts +1838 -0
  299. package/src/core/schema/mode/interfaces/README.md +278 -0
  300. package/src/core/schema/mode/interfaces/conditional/evaluator/ConditionalEvaluator.ts +657 -0
  301. package/src/core/schema/mode/interfaces/conditional/parser/ConditionalAST.ts +826 -0
  302. package/src/core/schema/mode/interfaces/conditional/parser/ConditionalLexer.ts +992 -0
  303. package/src/core/schema/mode/interfaces/conditional/parser/ConditionalParser.ts +803 -0
  304. package/src/core/schema/mode/interfaces/conditional/parser/readme.md +406 -0
  305. package/src/core/schema/mode/interfaces/conditional/types/ConditionalTypes.ts +273 -0
  306. package/src/core/schema/mode/interfaces/errors/ErrorHandler.ts +624 -0
  307. package/src/core/schema/mode/interfaces/errors/types/errors.type.ts +102 -0
  308. package/src/core/schema/mode/interfaces/precompilation/FieldPrecompilers.ts +962 -0
  309. package/src/core/schema/mode/interfaces/precompilation/SchemaPrecompiler.ts +667 -0
  310. package/src/core/schema/mode/interfaces/typescript/ConditionalTypes.ts +1534 -0
  311. package/src/core/schema/mode/interfaces/typescript/IDESupport.ts +534 -0
  312. package/src/core/schema/mode/interfaces/typescript/TypeInference.ts +737 -0
  313. package/src/core/schema/mode/interfaces/typescript/index.ts +92 -0
  314. package/src/core/schema/mode/interfaces/validators/ConstraintParser.ts +1438 -0
  315. package/src/core/schema/mode/interfaces/validators/EnhancedErrorReporting.ts +227 -0
  316. package/src/core/schema/mode/interfaces/validators/TypeGuards.ts +288 -0
  317. package/src/core/schema/mode/interfaces/validators/TypeValidators.ts +660 -0
  318. package/src/core/schema/mode/interfaces/validators/UnionCache.ts +508 -0
  319. package/src/core/schema/mode/interfaces/validators/ValidationHelpers.ts +1257 -0
  320. package/src/core/schema/mode/interfaces/validators/index.ts +21 -0
  321. package/src/core/schema/mode/interfaces/validators/mods/passValidator.ts +424 -0
  322. package/src/core/schema/mode/interfaces/validators/mods/securityValidator.ts +1634 -0
  323. package/src/core/schema/mode/interfaces/validators/mods/urlValidation.ts +333 -0
  324. package/src/core/schema/optimization/ObjectValidationCache.ts +560 -0
  325. package/src/core/schema/optimization/PerformanceInitializer.ts +188 -0
  326. package/src/core/schema/optimization/PerformanceMonitor.ts +898 -0
  327. package/src/core/schema/optimization/SchemaCompiler.ts +730 -0
  328. package/src/core/testing/TestDataGenerator.ts +590 -0
  329. package/src/core/types/SchemaValidator.type.ts +210 -0
  330. package/src/core/types/ValidatorTypes.ts +93 -0
  331. package/src/core/types/extension.type.ts +109 -0
  332. package/src/core/types/objValidationCache.ts +17 -0
  333. package/src/core/types/parser.type.ts +15 -0
  334. package/src/core/types/perfoMonitor.ts +37 -0
  335. package/src/core/types/scompiler.ts +22 -0
  336. package/src/core/types/securityValidator.type.ts +10 -0
  337. package/src/core/types/types.ts +154 -0
  338. package/src/core/utils/Make.ts +97 -0
  339. package/src/core/utils/Mod.ts +1168 -0
  340. package/src/core/utils/UrlArgs.ts +124 -0
  341. package/src/core/utils/arrayToEnum.ts +89 -0
  342. package/src/core/utils/createUrlArgsEnumFArray.ts +11 -0
  343. package/src/core/utils/securityHelpers.ts +341 -0
  344. package/src/core/utils/securityValidatorHelpers.ts +76 -0
  345. package/src/index.ts +124 -0
@@ -0,0 +1,1257 @@
1
+ /**
2
+ * Validation Helpers Module
3
+ *
4
+ * Contains optimized helper functions for validation operations
5
+ * extracted from InterfaceSchema to improve maintainability.
6
+ */
7
+
8
+ import {
9
+ SchemaValidationResult,
10
+ ValidationError,
11
+ } from "../../../../types/types";
12
+ import { VALIDATOR_TYPES } from "../../../../types/ValidatorTypes";
13
+ import {
14
+ UrlArgArray,
15
+ UrlArgsEnum,
16
+ UrlArgType,
17
+ } from "../../../../utils/UrlArgs";
18
+ import { SchemaOptions } from "../Interface";
19
+ import { TypeValidators } from "./TypeValidators";
20
+ import { OptimizedUnionValidator as OUV } from "./UnionCache";
21
+ import { ErrorHandler } from "../errors/ErrorHandler";
22
+ import { ErrorCode } from "../errors/types/errors.type";
23
+
24
+ // Cache for parsed constant values with LRU eviction
25
+ const MAX_CACHE_SIZE = 1000;
26
+ const constantCache = new Map<string, any>();
27
+
28
+ // Pre-compiled regex patterns for better performance
29
+ const NUMERIC_PATTERN = /^-?\d+(\.\d+)?([eE][+-]?\d+)?$/;
30
+ const BOOLEAN_PATTERN = /^(true|false|TRUE|FALSE|True|False)$/i;
31
+ const HEX_COLOR_PATTERN = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/;
32
+ const BASE64_PATTERN = /^[A-Za-z0-9+/]*={0,2}$/;
33
+ const JWT_PATTERN = /^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/;
34
+ const SEMVER_PATTERN =
35
+ /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
36
+
37
+ /**
38
+ * Helper functions for validation operations
39
+ */
40
+ export class ValidationHelpers {
41
+ /**
42
+ * Validate constant types (e.g., "=admin", "=user")
43
+ * with better caching, type safety, and deep equality checks
44
+ */
45
+ static validateConstantType(
46
+ constantValue: string,
47
+ value: any
48
+ ): SchemaValidationResult {
49
+ // Validate constant types with caching
50
+ // Implement LRU cache behavior
51
+ if (constantCache.size >= MAX_CACHE_SIZE) {
52
+ const firstKey = constantCache.keys().next().value;
53
+ constantCache.delete(firstKey || "");
54
+ }
55
+
56
+ let expectedValue = constantCache.get(constantValue);
57
+
58
+ if (expectedValue === undefined) {
59
+ try {
60
+ expectedValue = this.parseConstantValue(constantValue);
61
+ constantCache.set(constantValue, expectedValue);
62
+ } catch (error) {
63
+ return this.createErrorResult(
64
+ `Invalid constant value format: ${constantValue}`,
65
+ value
66
+ );
67
+ }
68
+ }
69
+
70
+ // equality check including deep object/array comparison
71
+ if (!this.deepEquals(value, expectedValue)) {
72
+ return this.createErrorResult(
73
+ `Expected constant value: ${JSON.stringify(expectedValue)}, got ${JSON.stringify(value)}`,
74
+ value
75
+ );
76
+ }
77
+
78
+ return this.createSuccessResult(value);
79
+ }
80
+
81
+ /**
82
+ * deep equality check for constants
83
+ */
84
+ static deepEquals(a: any, b: any): boolean {
85
+ if (a === b) return true;
86
+
87
+ if (a == null || b == null) return a === b;
88
+
89
+ if (typeof a !== typeof b) return false;
90
+
91
+ if (Array.isArray(a) && Array.isArray(b)) {
92
+ if (a.length !== b.length) return false;
93
+ return a.every((val, index) => this.deepEquals(val, b[index]));
94
+ }
95
+
96
+ if (typeof a === "object" && typeof b === "object") {
97
+ const keysA = Object.keys(a);
98
+ const keysB = Object.keys(b);
99
+ if (keysA.length !== keysB.length) return false;
100
+ return keysA.every(
101
+ (key) => keysB.includes(key) && this.deepEquals(a[key], b[key])
102
+ );
103
+ }
104
+
105
+ return false;
106
+ }
107
+
108
+ /**
109
+ * constant value parser with better error handling and type support
110
+ */
111
+ private static parseConstantValue(constantValue: string): any {
112
+ if (!constantValue || typeof constantValue !== "string") {
113
+ throw new Error("Invalid constant value");
114
+ }
115
+
116
+ // Handle quoted strings (remove quotes and return as string)
117
+ if (
118
+ (constantValue.startsWith('"') && constantValue.endsWith('"')) ||
119
+ (constantValue.startsWith("'") && constantValue.endsWith("'"))
120
+ ) {
121
+ return constantValue.slice(1, -1);
122
+ }
123
+
124
+ // numeric check with scientific notation support
125
+ if (NUMERIC_PATTERN.test(constantValue)) {
126
+ const num = parseFloat(constantValue);
127
+ if (isNaN(num) || !isFinite(num)) {
128
+ throw new Error("Invalid numeric constant");
129
+ }
130
+ return num;
131
+ }
132
+
133
+ // boolean check (case insensitive)
134
+ if (BOOLEAN_PATTERN.test(constantValue)) {
135
+ return constantValue.toLowerCase() === "true";
136
+ }
137
+
138
+ // Array check with validation
139
+ if (constantValue.startsWith("[") && constantValue.endsWith("]")) {
140
+ try {
141
+ const parsed = JSON.parse(constantValue);
142
+ if (!Array.isArray(parsed)) {
143
+ throw new Error("Invalid array format");
144
+ }
145
+ return parsed;
146
+ } catch (error) {
147
+ throw new Error("Invalid JSON array format");
148
+ }
149
+ }
150
+
151
+ // Object check with validation
152
+ if (constantValue.startsWith("{") && constantValue.endsWith("}")) {
153
+ try {
154
+ const parsed = JSON.parse(constantValue);
155
+ if (typeof parsed !== "object" || Array.isArray(parsed)) {
156
+ throw new Error("Invalid object format");
157
+ }
158
+ return parsed;
159
+ } catch (error) {
160
+ throw new Error("Invalid JSON object format");
161
+ }
162
+ }
163
+
164
+ // special values
165
+ switch (constantValue.toLowerCase()) {
166
+ case "null":
167
+ return null;
168
+ case "undefined":
169
+ return undefined;
170
+ case "nan":
171
+ return NaN;
172
+ case "infinity":
173
+ return Infinity;
174
+ case "-infinity":
175
+ return -Infinity;
176
+ default:
177
+ return constantValue;
178
+ }
179
+ }
180
+
181
+ /**
182
+ * union type validation with better error messages and nested union support
183
+ */
184
+ static validateUnionType(
185
+ unionType: string,
186
+ value: any
187
+ ): SchemaValidationResult {
188
+ if (!unionType || typeof unionType !== "string") {
189
+ return this.createErrorResult("Invalid union type definition", value);
190
+ }
191
+
192
+ try {
193
+ // Split union into parts
194
+ const unionParts = unionType.split("|").map((part) => part.trim());
195
+
196
+ // Check if this is a type union (contains basic types) or literal union
197
+ const basicTypes = new Set([
198
+ "string",
199
+ "number",
200
+ "boolean",
201
+ "date",
202
+ "any",
203
+ "null",
204
+ "undefined",
205
+ ]);
206
+ const isTypeUnion = unionParts.some((part) => basicTypes.has(part));
207
+
208
+ if (isTypeUnion) {
209
+ // Handle type union - validate that value matches one of the types
210
+ for (const type of unionParts) {
211
+ const typeResult = this.validateSingleType(type, value);
212
+ if (typeResult.success) {
213
+ return this.createSuccessResult(value);
214
+ }
215
+ }
216
+
217
+ // None of the types matched
218
+ return this.createErrorResult(
219
+ `Expected one of types: ${unionParts.join(", ")}, got ${typeof value}`,
220
+ value
221
+ );
222
+ } else {
223
+ // Handle literal union - use the optimized literal validator
224
+ const result = OUV.validateUnion(unionType, value);
225
+
226
+ if (!result.isValid) {
227
+ return this.createErrorResult(
228
+ result.error ||
229
+ `Expected one of: ${unionParts.join(", ")}, got ${value}`,
230
+ value
231
+ );
232
+ }
233
+
234
+ return this.createSuccessResult(value);
235
+ }
236
+ } catch (error) {
237
+ return this.createErrorResult(
238
+ `Union type validation error: ${error instanceof Error ? error.message : "Unknown error"}`,
239
+ value
240
+ );
241
+ }
242
+ }
243
+
244
+ /**
245
+ * Validate a single type (helper for type unions)
246
+ */
247
+ private static validateSingleType(
248
+ type: string,
249
+ value: any
250
+ ): SchemaValidationResult {
251
+ switch (type) {
252
+ case "string":
253
+ return typeof value === "string"
254
+ ? this.createSuccessResult(value)
255
+ : this.createErrorResult(
256
+ `Expected string, got ${typeof value}`,
257
+ value
258
+ );
259
+
260
+ case "number":
261
+ return typeof value === "number" && !isNaN(value)
262
+ ? this.createSuccessResult(value)
263
+ : this.createErrorResult(
264
+ `Expected number, got ${typeof value}`,
265
+ value
266
+ );
267
+
268
+ case "boolean":
269
+ return typeof value === "boolean"
270
+ ? this.createSuccessResult(value)
271
+ : this.createErrorResult(
272
+ `Expected boolean, got ${typeof value}`,
273
+ value
274
+ );
275
+
276
+ case "date":
277
+ return value instanceof Date
278
+ ? this.createSuccessResult(value)
279
+ : this.createErrorResult(
280
+ `Expected Date object, got ${typeof value}`,
281
+ value
282
+ );
283
+
284
+ case "any":
285
+ return this.createSuccessResult(value);
286
+
287
+ case "null":
288
+ return value === null
289
+ ? this.createSuccessResult(value)
290
+ : this.createErrorResult(`Expected null, got ${typeof value}`, value);
291
+
292
+ case "undefined":
293
+ return value === undefined
294
+ ? this.createSuccessResult(value)
295
+ : this.createErrorResult(
296
+ `Expected undefined, got ${typeof value}`,
297
+ value
298
+ );
299
+
300
+ default:
301
+ // For other types, delegate to the type validation system
302
+ return this.routeTypeValidation(type, value, {}, {});
303
+ }
304
+ }
305
+
306
+ /**
307
+ * record type validation with better type safety and performance
308
+ */
309
+ static validateRecordType(
310
+ type: string,
311
+ value: any,
312
+ validateFieldType: (fieldType: string, value: any) => SchemaValidationResult
313
+ ): SchemaValidationResult {
314
+ if (!type || typeof type !== "string") {
315
+ return this.createErrorResult("Invalid record type definition", value);
316
+ }
317
+
318
+ const recordMatch = type.match(/^record<([^,]+),(.+)>$/);
319
+
320
+ if (!recordMatch) {
321
+ return this.createErrorResult(
322
+ `Invalid Record type format: ${type}. Expected format: record<KeyType,ValueType>`,
323
+ value
324
+ );
325
+ }
326
+
327
+ if (value === null || value === undefined) {
328
+ return this.createErrorResult(
329
+ "Record cannot be null or undefined",
330
+ value
331
+ );
332
+ }
333
+
334
+ if (typeof value !== "object" || Array.isArray(value)) {
335
+ return this.createErrorResult(
336
+ `Expected object for Record type, got ${Array.isArray(value) ? "array" : typeof value}`,
337
+ value
338
+ );
339
+ }
340
+
341
+ const [, keyType, valueType] = recordMatch;
342
+ const trimmedKeyType = keyType.trim();
343
+ const trimmedValueType = valueType.trim();
344
+ const errors: ValidationError[] = [];
345
+ const validatedRecord: Record<string, any> = {};
346
+
347
+ // validation with proper key type checking
348
+ for (const [key, val] of Object.entries(value)) {
349
+ // Validate key type more comprehensively
350
+ if (!this.validateKeyType(key, trimmedKeyType)) {
351
+ errors.push(
352
+ ErrorHandler.createError(
353
+ [key],
354
+ `Record key "${key}" must be of type ${trimmedKeyType}, got ${typeof key}`,
355
+ ErrorCode.TYPE_ERROR,
356
+ trimmedKeyType,
357
+ key
358
+ )
359
+ );
360
+ continue;
361
+ }
362
+
363
+ // Validate value type
364
+ const valueResult = validateFieldType(trimmedValueType, val);
365
+ if (!valueResult.success) {
366
+ // Add path context to nested errors
367
+ const nestedErrors = valueResult.errors.map((error) => ({
368
+ ...error,
369
+ path: [key, ...error.path],
370
+ }));
371
+ errors.push(...nestedErrors);
372
+ } else {
373
+ validatedRecord[key] = valueResult.data;
374
+ }
375
+ }
376
+
377
+ if (errors.length > 0) {
378
+ return {
379
+ success: false,
380
+ errors,
381
+ warnings: [],
382
+ data: value,
383
+ };
384
+ }
385
+
386
+ return this.createSuccessResult(validatedRecord);
387
+ }
388
+
389
+ /**
390
+ * key type validation for records
391
+ */
392
+ private static validateKeyType(key: string, keyType: string): boolean {
393
+ switch (keyType) {
394
+ case "string":
395
+ return typeof key === "string";
396
+ case "number":
397
+ return !isNaN(Number(key)) && isFinite(Number(key));
398
+ case "int":
399
+ case "integer":
400
+ return Number.isInteger(Number(key));
401
+ default:
402
+ return typeof key === "string"; // Default to string for unknown key types
403
+ }
404
+ }
405
+
406
+ /**
407
+ * array validation with better constraint handling and performance
408
+ */
409
+ static validateArrayWithConstraints(
410
+ value: any,
411
+ elementType: string,
412
+ constraints: any,
413
+ validateElementType: (
414
+ elementType: string,
415
+ value: any
416
+ ) => SchemaValidationResult
417
+ ): SchemaValidationResult {
418
+ if (!Array.isArray(value)) {
419
+ return this.createErrorResult(
420
+ `Expected array, got ${value === null ? "null" : typeof value}`,
421
+ value
422
+ );
423
+ }
424
+
425
+ // constraint validation
426
+ const constraintErrors = this.validateArrayConstraints(value, constraints);
427
+ if (constraintErrors.length > 0) {
428
+ return {
429
+ success: false,
430
+ errors: constraintErrors,
431
+ warnings: [],
432
+ data: value,
433
+ };
434
+ }
435
+
436
+ // Validate elements with better error aggregation
437
+ const validatedArray: any[] = [];
438
+ const errors: ValidationError[] = [];
439
+ const warnings: string[] = [];
440
+
441
+ for (let i = 0; i < value.length; i++) {
442
+ const elementResult = validateElementType(elementType, value[i]);
443
+ if (!elementResult.success) {
444
+ // Add index to error paths
445
+ const indexedErrors = elementResult.errors.map((error) => ({
446
+ ...error,
447
+ path: [i.toString(), ...error.path],
448
+ }));
449
+ errors.push(...indexedErrors);
450
+ } else {
451
+ validatedArray.push(elementResult.data);
452
+ if (elementResult.warnings.length > 0) {
453
+ warnings.push(
454
+ `Element at index ${i}: ${elementResult.warnings.join(", ")}`
455
+ );
456
+ }
457
+ }
458
+ }
459
+
460
+ if (errors.length > 0) {
461
+ return {
462
+ success: false,
463
+ errors,
464
+ warnings,
465
+ data: value,
466
+ };
467
+ }
468
+
469
+ // uniqueness check
470
+ if (constraints.unique) {
471
+ const uniqueCheck = this.checkArrayUniqueness(validatedArray);
472
+ if (!uniqueCheck.success) {
473
+ return uniqueCheck;
474
+ }
475
+ }
476
+
477
+ return this.createSuccessResult(validatedArray, warnings);
478
+ }
479
+
480
+ /**
481
+ * array constraints validation with more constraint types
482
+ */
483
+ private static validateArrayConstraints(
484
+ value: any[],
485
+ constraints: any
486
+ ): ValidationError[] {
487
+ const errors: ValidationError[] = [];
488
+
489
+ if (!constraints) return errors;
490
+
491
+ if (
492
+ constraints.minItems !== undefined &&
493
+ value.length < constraints.minItems
494
+ ) {
495
+ errors.push(
496
+ ErrorHandler.createArrayError(
497
+ [],
498
+ `must have at least ${constraints.minItems} items, got ${value.length}`,
499
+ value,
500
+ ErrorCode.ARRAY_TOO_SHORT
501
+ )
502
+ );
503
+ }
504
+
505
+ if (
506
+ constraints.maxItems !== undefined &&
507
+ value.length > constraints.maxItems
508
+ ) {
509
+ errors.push(
510
+ ErrorHandler.createArrayError(
511
+ [],
512
+ `must have at most ${constraints.maxItems} items, got ${value.length}`,
513
+ value,
514
+ ErrorCode.ARRAY_TOO_LONG
515
+ )
516
+ );
517
+ }
518
+
519
+ if (
520
+ constraints.exactItems !== undefined &&
521
+ value.length !== constraints.exactItems
522
+ ) {
523
+ errors.push(
524
+ ErrorHandler.createArrayError(
525
+ [],
526
+ `must have exactly ${constraints.exactItems} items, got ${value.length}`,
527
+ value,
528
+ ErrorCode.ARRAY_TOO_SHORT
529
+ )
530
+ );
531
+ }
532
+
533
+ return errors;
534
+ }
535
+
536
+ /**
537
+ * array uniqueness check with better performance and type handling
538
+ */
539
+ private static checkArrayUniqueness(array: any[]): SchemaValidationResult {
540
+ const seen = new Set();
541
+ const duplicates: any[] = [];
542
+
543
+ for (let i = 0; i < array.length; i++) {
544
+ const item = array[i];
545
+ let key: string;
546
+
547
+ try {
548
+ key =
549
+ typeof item === "object" && item !== null
550
+ ? JSON.stringify(item, Object.keys(item).sort()) // Consistent object serialization
551
+ : String(item);
552
+ } catch (error) {
553
+ // Handle circular references or non-serializable objects
554
+ key = `[object-${i}]`;
555
+ }
556
+
557
+ if (seen.has(key)) {
558
+ duplicates.push(item);
559
+ } else {
560
+ seen.add(key);
561
+ }
562
+ }
563
+
564
+ if (duplicates.length > 0) {
565
+ return this.createErrorResult(
566
+ `Array values must be unique. Duplicate values found: ${duplicates.map((d) => JSON.stringify(d)).join(", ")}`,
567
+ array
568
+ );
569
+ }
570
+
571
+ return this.createSuccessResult(array);
572
+ }
573
+
574
+ /**
575
+ * optional value handling with better default value support
576
+ */
577
+ static handleOptionalValue(
578
+ value: any,
579
+ isOptional: boolean,
580
+ defaultValue?: any
581
+ ): SchemaValidationResult | null {
582
+ if (value === undefined) {
583
+ if (isOptional) {
584
+ return this.createSuccessResult(
585
+ defaultValue !== undefined ? defaultValue : undefined
586
+ );
587
+ } else {
588
+ return this.createErrorResult("Required field is missing or undefined");
589
+ }
590
+ }
591
+
592
+ if (value === null) {
593
+ if (isOptional) {
594
+ return this.createSuccessResult(null);
595
+ } else {
596
+ return this.createErrorResult("Required field cannot be null");
597
+ }
598
+ }
599
+
600
+ return null; // Continue with normal validation
601
+ }
602
+
603
+ /**
604
+ * Check if type is a conditional expression using secure regex pattern
605
+ */
606
+ private static isConditionalExpression(type: string): boolean {
607
+ // Secure regex pattern to match: when <condition> *? <thenValue> [: <elseValue>]
608
+ const conditionalPattern = /^\s*when\s+.+?\s*\*\?\s*.+/;
609
+ return conditionalPattern.test(type);
610
+ }
611
+
612
+ /**
613
+ * type validation routing with new types and better error handling
614
+ */
615
+ static routeTypeValidation(
616
+ type: string,
617
+ value: any,
618
+ options: SchemaOptions,
619
+ constraints: any,
620
+ required: boolean = false
621
+ ): SchemaValidationResult {
622
+ // Debug logging
623
+
624
+ // Check for conditional expressions first
625
+ if (this.isConditionalExpression(type)) {
626
+ // Conditional expressions should not be validated here
627
+ // They should be handled by the conditional validation system
628
+ // Return an error indicating this is not supported in this context
629
+ const result: SchemaValidationResult = {
630
+ success: false,
631
+ errors: [
632
+ ErrorHandler.createValidationError(
633
+ [],
634
+ `Unknown or unsupported type: ${type}. Please check the type definition.`,
635
+ value
636
+ ),
637
+ ],
638
+ warnings: [],
639
+ data: value,
640
+ };
641
+ return result;
642
+ }
643
+ if (!type || typeof type !== "string") {
644
+ return this.createErrorResult("Invalid type definition", value);
645
+ }
646
+ // Handle array types first (e.g., "string[]", "number[]", etc.)
647
+ if (type.endsWith("[]")) {
648
+ const elementType = type.slice(0, -2);
649
+ return this.validateArrayWithConstraints(
650
+ value,
651
+ elementType,
652
+ constraints,
653
+ (elementType: string, elementValue: any) =>
654
+ this.routeTypeValidation(elementType, elementValue, options, {})
655
+ );
656
+ }
657
+
658
+ // Handle Record types first (both lowercase and TypeScript-style uppercase)
659
+ if (
660
+ (type.startsWith("record<") && type.endsWith(">")) ||
661
+ (type.startsWith("Record<") && type.endsWith(">"))
662
+ ) {
663
+ // Normalize to lowercase for the validator
664
+ const normalizedType = type.startsWith("Record<")
665
+ ? "record<" + type.slice(7)
666
+ : type;
667
+
668
+ return this.validateRecordType(
669
+ normalizedType,
670
+ value,
671
+ (fieldType: string, value: any) =>
672
+ this.routeTypeValidation(fieldType, value, options, {})
673
+ );
674
+ }
675
+
676
+ const urlType = type.startsWith("url"); // Case-sensitive URL detection
677
+
678
+ if (urlType) {
679
+ // For basic "url" type, use "url.web" as default
680
+ const urlArgType = type === "url" ? UrlArgsEnum.web : type;
681
+
682
+ // Validate URL arg before proceeding
683
+ if (urlArgType !== UrlArgsEnum.web) {
684
+ // Check if it's a valid URL arg
685
+ if (!UrlArgArray.includes(urlArgType as any)) {
686
+ const error = this.createValidationError(
687
+ [],
688
+ `Invalid URL argument: ${urlArgType}. Valid arguments are: ${UrlArgArray.join(", ")}`,
689
+ "INVALID_URL_ARGUMENT",
690
+ `url.${UrlArgArray.join("|url.")}`,
691
+ value,
692
+ {
693
+ allowedValues: [...UrlArgArray],
694
+ suggestion: `Use one of: ${UrlArgArray.join(", ")}`,
695
+ }
696
+ );
697
+
698
+ return {
699
+ success: false,
700
+ errors: [error],
701
+ warnings: [],
702
+ data: value,
703
+ };
704
+ }
705
+ }
706
+
707
+ return TypeValidators.validateUrl(value, urlArgType as UrlArgType);
708
+ }
709
+
710
+ // switch with new types and better grouping
711
+ // switch with new types and better grouping using VALIDATOR_TYPES enum
712
+ switch (type.toLowerCase()) {
713
+ case VALIDATOR_TYPES.STRING:
714
+ return TypeValidators.validateString(
715
+ value,
716
+ options,
717
+ constraints,
718
+ required
719
+ );
720
+
721
+ case VALIDATOR_TYPES.NUMBER:
722
+ case VALIDATOR_TYPES.FLOAT:
723
+ return TypeValidators.validateNumber(
724
+ value,
725
+ options,
726
+ constraints,
727
+ required
728
+ );
729
+
730
+ case VALIDATOR_TYPES.INT:
731
+ case VALIDATOR_TYPES.INTEGER:
732
+ console.log("Got int value");
733
+ return TypeValidators.validateInteger(
734
+ value,
735
+ options,
736
+ constraints,
737
+ type as "int" | "integer"
738
+ );
739
+
740
+ case VALIDATOR_TYPES.POSITIVE:
741
+ case VALIDATOR_TYPES.NEGATIVE:
742
+ console.log("Got positive/negative value");
743
+ return TypeValidators.validateNumber(
744
+ value,
745
+ options,
746
+ { ...constraints, type },
747
+ required
748
+ );
749
+
750
+ case VALIDATOR_TYPES.DOUBLE:
751
+ return TypeValidators.validateFloat(
752
+ value,
753
+ options,
754
+ constraints,
755
+ "double"
756
+ );
757
+
758
+ case VALIDATOR_TYPES.BOOLEAN:
759
+ case VALIDATOR_TYPES.BOOL:
760
+ return TypeValidators.validateBoolean(value, options, constraints);
761
+
762
+ case VALIDATOR_TYPES.DATE:
763
+ case VALIDATOR_TYPES.DATETIME:
764
+ case VALIDATOR_TYPES.TIMESTAMP:
765
+ return TypeValidators.validateDate(
766
+ value,
767
+ options,
768
+ constraints,
769
+ type as "date" | "datetime" | "timestamp"
770
+ );
771
+
772
+ case VALIDATOR_TYPES.EMAIL:
773
+ return TypeValidators.validateEmail(value);
774
+
775
+ case VALIDATOR_TYPES.UUID:
776
+ case VALIDATOR_TYPES.GUID:
777
+ return TypeValidators.validateUuid(value, type as "uuid" | "guid");
778
+
779
+ case VALIDATOR_TYPES.PHONE:
780
+ return TypeValidators.validatePhone(value);
781
+
782
+ case VALIDATOR_TYPES.SLUG:
783
+ return TypeValidators.validateSlug(value);
784
+
785
+ case VALIDATOR_TYPES.USERNAME:
786
+ return TypeValidators.validateUsername(value);
787
+
788
+ case VALIDATOR_TYPES.IP:
789
+ return TypeValidators.validateIp(value);
790
+
791
+ case VALIDATOR_TYPES.PASSWORD:
792
+ return TypeValidators.validatePassword(value);
793
+
794
+ case VALIDATOR_TYPES.TEXT:
795
+ return TypeValidators.validateText(value, {});
796
+
797
+ case VALIDATOR_TYPES.JSON:
798
+ return TypeValidators.validateJson(value, { securityMode: "fast" }); // Default to fast
799
+
800
+ case "json.fast":
801
+ return TypeValidators.validateJson(value, { securityMode: "fast" });
802
+
803
+ case "json.secure":
804
+ return TypeValidators.validateJson(value, { securityMode: "secure" });
805
+
806
+ case VALIDATOR_TYPES.OBJECT:
807
+ return TypeValidators.validateObject(value);
808
+
809
+ case VALIDATOR_TYPES.UNKNOWN:
810
+ case VALIDATOR_TYPES.VOID:
811
+ case VALIDATOR_TYPES.NULL:
812
+ case VALIDATOR_TYPES.UNDEFINED:
813
+ case VALIDATOR_TYPES.ANY:
814
+ return TypeValidators.validateSpecialType(
815
+ value,
816
+ type as "unknown" | "void" | "null" | "undefined" | "any"
817
+ );
818
+
819
+ // NEW TYPE CASES
820
+ case VALIDATOR_TYPES.HEXCOLOR:
821
+ return this.validateHexColor(value);
822
+
823
+ case VALIDATOR_TYPES.BASE64:
824
+ return this.validateBase64(value);
825
+
826
+ case VALIDATOR_TYPES.JWT:
827
+ return this.validateJWT(value);
828
+
829
+ case VALIDATOR_TYPES.SEMVER:
830
+ return this.validateSemVer(value);
831
+
832
+ default:
833
+ return this.createErrorResult(
834
+ `Unknown or unsupported type: ${type}. Please check the type definition.`,
835
+ value
836
+ );
837
+ }
838
+ }
839
+
840
+ /**
841
+ * NEW: Validate hex color codes (#RGB, #RRGGBB, #RRGGBBAA)
842
+ */
843
+ private static validateHexColor(value: any): SchemaValidationResult {
844
+ if (typeof value !== "string") {
845
+ return this.createErrorResult("Hex color must be a string", value);
846
+ }
847
+
848
+ if (!HEX_COLOR_PATTERN.test(value)) {
849
+ return this.createErrorResult(
850
+ "Invalid hex color format. Expected #RGB, #RRGGBB, or #RRGGBBAA",
851
+ value
852
+ );
853
+ }
854
+
855
+ return this.createSuccessResult(value.toUpperCase());
856
+ }
857
+
858
+ /**
859
+ * NEW: Validate Base64 encoded strings
860
+ */
861
+ private static validateBase64(value: any): SchemaValidationResult {
862
+ if (typeof value !== "string") {
863
+ return this.createErrorResult("Base64 must be a string", value);
864
+ }
865
+
866
+ if (value.length === 0) {
867
+ return this.createErrorResult("Base64 string cannot be empty", value);
868
+ }
869
+
870
+ if (value.length % 4 !== 0) {
871
+ return this.createErrorResult(
872
+ "Base64 string length must be multiple of 4",
873
+ value
874
+ );
875
+ }
876
+
877
+ if (!BASE64_PATTERN.test(value)) {
878
+ return this.createErrorResult("Invalid Base64 format", value);
879
+ }
880
+
881
+ try {
882
+ // Validate by attempting to decode
883
+ if (typeof atob !== "undefined") {
884
+ atob(value);
885
+ } else if (typeof Buffer !== "undefined") {
886
+ Buffer.from(value, "base64");
887
+ }
888
+ } catch (error) {
889
+ return this.createErrorResult("Invalid Base64 encoding", value);
890
+ }
891
+
892
+ return this.createSuccessResult(value);
893
+ }
894
+
895
+ /**
896
+ * NEW: Validate JWT (JSON Web Token) format
897
+ */
898
+ private static validateJWT(value: any): SchemaValidationResult {
899
+ if (typeof value !== "string") {
900
+ return this.createErrorResult("JWT must be a string", value);
901
+ }
902
+
903
+ if (!JWT_PATTERN.test(value)) {
904
+ return this.createErrorResult(
905
+ "Invalid JWT format. Expected three base64url segments separated by dots",
906
+ value
907
+ );
908
+ }
909
+
910
+ const parts = value.split(".");
911
+ if (parts.length !== 3) {
912
+ return this.createErrorResult("JWT must have exactly 3 parts", value);
913
+ }
914
+
915
+ // Validate each part is valid base64url
916
+ for (let i = 0; i < parts.length; i++) {
917
+ const part = parts[i];
918
+ if (!/^[A-Za-z0-9_-]+$/.test(part)) {
919
+ return this.createErrorResult(
920
+ `JWT part ${i + 1} contains invalid base64url characters`,
921
+ value
922
+ );
923
+ }
924
+ }
925
+
926
+ // Try to decode header and payload (not signature for security reasons)
927
+ try {
928
+ const header = JSON.parse(this.base64urlDecode(parts[0]));
929
+ const payload = JSON.parse(this.base64urlDecode(parts[1]));
930
+
931
+ if (!header.alg || !header.typ) {
932
+ return this.createErrorResult(
933
+ "JWT header missing required fields (alg, typ)",
934
+ value
935
+ );
936
+ }
937
+ } catch (error) {
938
+ return this.createErrorResult(
939
+ "JWT header or payload is not valid JSON",
940
+ value
941
+ );
942
+ }
943
+
944
+ return this.createSuccessResult(value);
945
+ }
946
+
947
+ /**
948
+ * NEW: Validate Semantic Versioning (SemVer) format
949
+ */
950
+ private static validateSemVer(value: any): SchemaValidationResult {
951
+ if (typeof value !== "string") {
952
+ return this.createErrorResult("SemVer must be a string", value);
953
+ }
954
+
955
+ if (!SEMVER_PATTERN.test(value)) {
956
+ return this.createErrorResult(
957
+ "Invalid SemVer format. Expected MAJOR.MINOR.PATCH[-PRERELEASE][+BUILD]",
958
+ value
959
+ );
960
+ }
961
+
962
+ const parts = value.split(".");
963
+ if (parts.length < 3) {
964
+ return this.createErrorResult(
965
+ "SemVer must have at least MAJOR.MINOR.PATCH",
966
+ value
967
+ );
968
+ }
969
+
970
+ // Validate major, minor, patch are valid numbers
971
+ const [major, minor] = parts;
972
+ const patchPart = parts[2].split("-")[0].split("+")[0]; // Remove prerelease and build
973
+
974
+ if (!Number.isInteger(Number(major)) || Number(major) < 0) {
975
+ return this.createErrorResult(
976
+ "SemVer major version must be a non-negative integer",
977
+ value
978
+ );
979
+ }
980
+
981
+ if (!Number.isInteger(Number(minor)) || Number(minor) < 0) {
982
+ return this.createErrorResult(
983
+ "SemVer minor version must be a non-negative integer",
984
+ value
985
+ );
986
+ }
987
+
988
+ if (!Number.isInteger(Number(patchPart)) || Number(patchPart) < 0) {
989
+ return this.createErrorResult(
990
+ "SemVer patch version must be a non-negative integer",
991
+ value
992
+ );
993
+ }
994
+
995
+ return this.createSuccessResult(value);
996
+ }
997
+
998
+ /**
999
+ * Helper: Base64url decode for JWT validation
1000
+ */
1001
+ private static base64urlDecode(str: string): string {
1002
+ // Convert base64url to base64
1003
+ let base64 = str.replace(/-/g, "+").replace(/_/g, "/");
1004
+
1005
+ // Pad with = if necessary
1006
+ while (base64.length % 4) {
1007
+ base64 += "=";
1008
+ }
1009
+
1010
+ try {
1011
+ if (typeof atob !== "undefined") {
1012
+ return atob(base64);
1013
+ } else if (typeof Buffer !== "undefined") {
1014
+ return Buffer.from(base64, "base64").toString();
1015
+ } else {
1016
+ throw new Error("No base64 decoder available");
1017
+ }
1018
+ } catch (error) {
1019
+ throw new Error("Invalid base64url encoding");
1020
+ }
1021
+ }
1022
+
1023
+ /**
1024
+ * result merging with better performance and warning handling
1025
+ */
1026
+ static mergeResults(
1027
+ results: SchemaValidationResult[]
1028
+ ): SchemaValidationResult {
1029
+ if (results.length === 0) {
1030
+ return this.createSuccessResult(undefined);
1031
+ }
1032
+
1033
+ if (results.length === 1) {
1034
+ return results[0];
1035
+ }
1036
+
1037
+ let success = true;
1038
+ const errors: ValidationError[] = [];
1039
+ const warnings: string[] = [];
1040
+ const mergedData: any[] = [];
1041
+
1042
+ for (const result of results) {
1043
+ if (!result.success) {
1044
+ success = false;
1045
+ }
1046
+ errors.push(...result.errors);
1047
+ warnings.push(...result.warnings);
1048
+
1049
+ if (result.data !== undefined) {
1050
+ mergedData.push(result.data);
1051
+ }
1052
+ }
1053
+
1054
+ // Remove duplicate errors by comparing path and message
1055
+ const uniqueErrors = errors.filter(
1056
+ (error, index, arr) =>
1057
+ arr.findIndex(
1058
+ (e) =>
1059
+ e.path.join(".") === error.path.join(".") &&
1060
+ e.message === error.message
1061
+ ) === index
1062
+ );
1063
+
1064
+ return {
1065
+ success,
1066
+ errors: uniqueErrors,
1067
+ warnings: [...new Set(warnings)], // Remove duplicates
1068
+ data: mergedData.length === 1 ? mergedData[0] : mergedData,
1069
+ };
1070
+ }
1071
+
1072
+ /**
1073
+ * Create rich error result with detailed information
1074
+ */
1075
+ static createErrorResult(
1076
+ error: string,
1077
+ value?: any,
1078
+ context?: string
1079
+ ): SchemaValidationResult {
1080
+ const errorObj = ErrorHandler.createError(
1081
+ context ? [context] : [],
1082
+ error,
1083
+ ErrorCode.VALIDATION_ERROR,
1084
+ "unknown",
1085
+ value
1086
+ );
1087
+
1088
+ return {
1089
+ success: false,
1090
+ errors: [errorObj],
1091
+ warnings: [],
1092
+ data: value,
1093
+ };
1094
+ }
1095
+
1096
+ /**
1097
+ * Create detailed validation error object
1098
+ */
1099
+ static createValidationError(
1100
+ path: string[],
1101
+ message: string,
1102
+ code: string,
1103
+ expected: string,
1104
+ received: any,
1105
+ context?: {
1106
+ suggestion?: string;
1107
+ allowedValues?: any[];
1108
+ constraints?: Record<string, any>;
1109
+ }
1110
+ ): ValidationError {
1111
+ return {
1112
+ path,
1113
+ message,
1114
+ code,
1115
+ expected,
1116
+ received,
1117
+ receivedType: this.getValueType(received),
1118
+ context,
1119
+ };
1120
+ }
1121
+
1122
+ /**
1123
+ * Create field validation error with path
1124
+ */
1125
+ static createFieldError(
1126
+ fieldPath: string,
1127
+ message: string,
1128
+ expected: string,
1129
+ received: any,
1130
+ code: string = "FIELD_VALIDATION_ERROR",
1131
+ suggestion?: string
1132
+ ): ValidationError {
1133
+ return this.createValidationError(
1134
+ fieldPath.split(".").filter((p) => p.length > 0),
1135
+ message,
1136
+ code,
1137
+ expected,
1138
+ received,
1139
+ suggestion ? { suggestion } : undefined
1140
+ );
1141
+ }
1142
+
1143
+ /**
1144
+ * Get detailed type information for values
1145
+ */
1146
+ static getValueType(value: any): string {
1147
+ if (value === null) return "null";
1148
+ if (value === undefined) return "undefined";
1149
+ if (Array.isArray(value)) return "array";
1150
+ if (value instanceof Date) return "date";
1151
+ if (value instanceof RegExp) return "regexp";
1152
+ return typeof value;
1153
+ }
1154
+
1155
+ /**
1156
+ * success result creation
1157
+ */
1158
+ static createSuccessResult(
1159
+ data: any,
1160
+ warnings: string[] = []
1161
+ ): SchemaValidationResult {
1162
+ return {
1163
+ success: true,
1164
+ errors: [],
1165
+ warnings: [...new Set(warnings)], // Remove duplicate warnings
1166
+ data,
1167
+ };
1168
+ }
1169
+
1170
+ /**
1171
+ * cache management with selective clearing
1172
+ */
1173
+ static clearCaches(cacheType?: "constant" | "all"): void {
1174
+ if (!cacheType || cacheType === "all" || cacheType === "constant") {
1175
+ constantCache.clear();
1176
+ }
1177
+ }
1178
+
1179
+ /**
1180
+ * cache statistics with memory usage estimation
1181
+ */
1182
+ static getCacheStats(): {
1183
+ constantCacheSize: number;
1184
+ constantCacheMemoryEstimate: number;
1185
+ } {
1186
+ let memoryEstimate = 0;
1187
+
1188
+ for (const [key, value] of constantCache.entries()) {
1189
+ memoryEstimate += key.length * 2; // String characters are 2 bytes each
1190
+ memoryEstimate += this.estimateObjectSize(value);
1191
+ }
1192
+
1193
+ return {
1194
+ constantCacheSize: constantCache.size,
1195
+ constantCacheMemoryEstimate: memoryEstimate,
1196
+ };
1197
+ }
1198
+
1199
+ /**
1200
+ * Estimate object size in bytes for cache statistics
1201
+ */
1202
+ private static estimateObjectSize(obj: any): number {
1203
+ if (obj === null || obj === undefined) return 8;
1204
+
1205
+ switch (typeof obj) {
1206
+ case "boolean":
1207
+ return 4;
1208
+ case "number":
1209
+ return 8;
1210
+ case "string":
1211
+ return obj.length * 2;
1212
+ case "object":
1213
+ if (Array.isArray(obj)) {
1214
+ return obj.reduce(
1215
+ (sum, item) => sum + this.estimateObjectSize(item),
1216
+ 24
1217
+ );
1218
+ }
1219
+ return Object.entries(obj).reduce(
1220
+ (sum, [key, value]) =>
1221
+ sum + key.length * 2 + this.estimateObjectSize(value),
1222
+ 24
1223
+ );
1224
+ default:
1225
+ return 8;
1226
+ }
1227
+ }
1228
+
1229
+ /**
1230
+ * validation with comprehensive error context
1231
+ */
1232
+ static validateWithContext(
1233
+ type: string,
1234
+ value: any,
1235
+ options: SchemaOptions,
1236
+ constraints: any,
1237
+ fieldPath?: string
1238
+ ): SchemaValidationResult {
1239
+ const result = this.routeTypeValidation(type, value, options, constraints);
1240
+
1241
+ if (!result.success && fieldPath) {
1242
+ // Update error paths with field context
1243
+ const updatedErrors = result.errors.map((error) => ({
1244
+ ...error,
1245
+ path: fieldPath.split(".").concat(error.path),
1246
+ message: error.message, // Keep original message, path provides context
1247
+ }));
1248
+
1249
+ return {
1250
+ ...result,
1251
+ errors: updatedErrors,
1252
+ };
1253
+ }
1254
+
1255
+ return result;
1256
+ }
1257
+ }