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,962 @@
1
+ /**
2
+ * Field-Specific Precompilers
3
+ *
4
+ * Each field type gets its own specialized precompiler for maximum performance
5
+ */
6
+
7
+ import {
8
+ SchemaValidationResult,
9
+ ValidationError,
10
+ } from "../../../../types/types";
11
+ import { ConstraintParser } from "../validators";
12
+ import { UnionCache } from "../validators/UnionCache";
13
+ import { ValidationHelpers } from "../validators/ValidationHelpers";
14
+ import { ErrorHandler } from "../errors/ErrorHandler";
15
+ import { ErrorCode } from "../errors/types/errors.type";
16
+
17
+ export interface CompiledFieldValidator {
18
+ (value: any): SchemaValidationResult;
19
+ _fieldType: string;
20
+ _isCompiled: true;
21
+ }
22
+
23
+ export class FieldPrecompilers {
24
+ /**
25
+ * Precompile union field validators
26
+ *
27
+ */
28
+ static precompileUnion(unionType: string): CompiledFieldValidator {
29
+ // Use the fixed union validation from ValidationHelpers
30
+ const validator = (value: any): SchemaValidationResult => {
31
+ return ValidationHelpers.validateUnionType(unionType, value);
32
+ };
33
+
34
+ (validator as any)._fieldType = unionType;
35
+ (validator as any)._isCompiled = true;
36
+
37
+ return validator as CompiledFieldValidator;
38
+ }
39
+
40
+ /**
41
+ * Precompile string field validators
42
+ */
43
+ static precompileString(
44
+ constraints: {
45
+ minLength?: number;
46
+ maxLength?: number;
47
+ pattern?: RegExp;
48
+ } = {}
49
+ ): CompiledFieldValidator {
50
+ const { minLength, maxLength, pattern } = constraints;
51
+
52
+ // Pre-compile validation logic based on constraints
53
+ if (!minLength && !maxLength && !pattern) {
54
+ // Simple string validation
55
+ const validator = (value: any): SchemaValidationResult => {
56
+ if (typeof value === "string") {
57
+ return {
58
+ success: true,
59
+ errors: [],
60
+ warnings: [],
61
+ data: value,
62
+ };
63
+ }
64
+ return {
65
+ success: false,
66
+ errors: [ErrorHandler.createTypeError([], "string", value)],
67
+ warnings: [],
68
+ data: undefined,
69
+ };
70
+ };
71
+
72
+ (validator as any)._fieldType = "string";
73
+ (validator as any)._isCompiled = true;
74
+ return validator as CompiledFieldValidator;
75
+ }
76
+
77
+ // OPTIMIZED: String with constraints
78
+ const validator = (value: any): SchemaValidationResult => {
79
+ if (typeof value !== "string") {
80
+ return {
81
+ success: false,
82
+ errors: [ErrorHandler.createTypeError([], "string", value)],
83
+ warnings: [],
84
+ data: undefined,
85
+ };
86
+ }
87
+
88
+ const errors: ValidationError[] = [];
89
+
90
+ if (minLength !== undefined && value.length < minLength) {
91
+ errors.push({
92
+ code: "STRING_TOO_SHORT",
93
+ message: `String must be at least ${minLength} characters`,
94
+ path: [],
95
+ expected: `string(minLength: ${minLength})`,
96
+ received: value,
97
+ receivedType: "string",
98
+ });
99
+ }
100
+
101
+ if (maxLength !== undefined && value.length > maxLength) {
102
+ errors.push({
103
+ code: "STRING_TOO_LONG",
104
+ message: `String must be at most ${maxLength} characters`,
105
+ path: [],
106
+ expected: `string(maxLength: ${maxLength})`,
107
+ received: value,
108
+ receivedType: "string",
109
+ });
110
+ }
111
+
112
+ if (pattern && !pattern.test(value)) {
113
+ errors.push({
114
+ code: "STRING_PATTERN_MISMATCH",
115
+ message: `String does not match required pattern`,
116
+ path: [],
117
+ expected: `string(pattern: ${pattern})`,
118
+ received: value,
119
+ receivedType: "string",
120
+ });
121
+ }
122
+
123
+ if (errors.length > 0) {
124
+ return {
125
+ success: false,
126
+ errors,
127
+ warnings: [],
128
+ data: undefined,
129
+ };
130
+ }
131
+
132
+ return {
133
+ success: true,
134
+ errors: [],
135
+ warnings: [],
136
+ data: value,
137
+ };
138
+ };
139
+
140
+ (validator as any)._fieldType =
141
+ `string(${minLength || ""},${maxLength || ""})`;
142
+ (validator as any)._isCompiled = true;
143
+ return validator as CompiledFieldValidator;
144
+ }
145
+
146
+ /**
147
+ * Precompile float field validators (for float and double types)
148
+ */
149
+ static precompileFloat(
150
+ constraints: { min?: number; max?: number } = {}
151
+ ): CompiledFieldValidator {
152
+ const { min, max } = constraints;
153
+
154
+ const validator = (value: any): SchemaValidationResult => {
155
+ // DEBUG: Add logging to see what's happening
156
+ // console.log("🔍 precompileFloat validator executing:");
157
+ // console.log(" - value:", value, "type:", typeof value);
158
+ // console.log(" - constraints: min =", min, ", max =", max);
159
+
160
+ if (typeof value !== "number" || isNaN(value) || !isFinite(value)) {
161
+ // console.log(" - FAIL: not a valid number");
162
+ return {
163
+ success: false,
164
+ errors: [ErrorHandler.createTypeError([], "float", value)],
165
+ warnings: [],
166
+ data: undefined,
167
+ };
168
+ }
169
+
170
+ const errors: ValidationError[] = [];
171
+
172
+ if (min !== undefined && value < min) {
173
+ // console.log(" - FAIL: value", value, "< min", min);
174
+ errors.push({
175
+ code: ErrorCode.NUMBER_TOO_SMALL,
176
+ message: `Float must be at least ${min}`,
177
+ path: [],
178
+ expected: `float(min: ${min})`,
179
+ received: value,
180
+ receivedType: "number",
181
+ });
182
+ }
183
+
184
+ if (max !== undefined && value > max) {
185
+ // console.log(" - FAIL: value", value, "> max", max);
186
+ errors.push({
187
+ code: ErrorCode.NUMBER_TOO_LARGE,
188
+ message: `Float must be at most ${max}`,
189
+ path: [],
190
+ expected: `float(max: ${max})`,
191
+ received: value,
192
+ receivedType: "number",
193
+ });
194
+ }
195
+
196
+ if (errors.length > 0) {
197
+ // console.log(" - FINAL RESULT: FAIL with errors:", errors);
198
+ return {
199
+ success: false,
200
+ errors,
201
+ warnings: [],
202
+ data: undefined,
203
+ };
204
+ }
205
+
206
+ // console.log(" - FINAL RESULT: PASS");
207
+ return {
208
+ success: true,
209
+ errors: [],
210
+ warnings: [],
211
+ data: value,
212
+ };
213
+ };
214
+
215
+ (validator as any)._fieldType = `float(${min || ""},${max || ""})`;
216
+ (validator as any)._isCompiled = true;
217
+ return validator as CompiledFieldValidator;
218
+ }
219
+
220
+ /**
221
+ * Precompile positive number field validators
222
+ */
223
+ static precompilePositiveNumber(
224
+ constraints: { min?: number; max?: number } = {}
225
+ ): CompiledFieldValidator {
226
+ const { min, max } = constraints;
227
+
228
+ const validator = (value: any): SchemaValidationResult => {
229
+ if (typeof value !== "number" || isNaN(value) || !isFinite(value)) {
230
+ return {
231
+ success: false,
232
+ errors: [ErrorHandler.createTypeError([], "positive number", value)],
233
+ warnings: [],
234
+ data: undefined,
235
+ };
236
+ }
237
+
238
+ const errors: ValidationError[] = [];
239
+
240
+ // CRITICAL: Positive validation - must be > 0
241
+ if (value <= 0) {
242
+ errors.push({
243
+ code: "NUMBER_NOT_POSITIVE",
244
+ message: "Number must be positive",
245
+ path: [],
246
+ expected: "positive",
247
+ received: value,
248
+ receivedType: "number",
249
+ });
250
+ }
251
+
252
+ if (min !== undefined && value < min) {
253
+ errors.push({
254
+ code: ErrorCode.NUMBER_TOO_SMALL,
255
+ message: `Number must be at least ${min}`,
256
+ path: [],
257
+ expected: `positive(min: ${min})`,
258
+ received: value,
259
+ receivedType: "number",
260
+ });
261
+ }
262
+
263
+ if (max !== undefined && value > max) {
264
+ errors.push({
265
+ code: ErrorCode.NUMBER_TOO_LARGE,
266
+ message: `Number must be at most ${max}`,
267
+ path: [],
268
+ expected: `positive(max: ${max})`,
269
+ received: value,
270
+ receivedType: "number",
271
+ });
272
+ }
273
+
274
+ if (errors.length > 0) {
275
+ return {
276
+ success: false,
277
+ errors,
278
+ warnings: [],
279
+ data: undefined,
280
+ };
281
+ }
282
+
283
+ return {
284
+ success: true,
285
+ errors: [],
286
+ warnings: [],
287
+ data: value,
288
+ };
289
+ };
290
+
291
+ (validator as any)._fieldType = `positive(${min || ""},${max || ""})`;
292
+ (validator as any)._isCompiled = true;
293
+ return validator as CompiledFieldValidator;
294
+ }
295
+
296
+ /**
297
+ * Precompile negative number field validators
298
+ */
299
+ static precompileNegativeNumber(
300
+ constraints: { min?: number; max?: number } = {}
301
+ ): CompiledFieldValidator {
302
+ const { min, max } = constraints;
303
+
304
+ const validator = (value: any): SchemaValidationResult => {
305
+ if (typeof value !== "number" || isNaN(value) || !isFinite(value)) {
306
+ return {
307
+ success: false,
308
+ errors: [ErrorHandler.createTypeError([], "negative number", value)],
309
+ warnings: [],
310
+ data: undefined,
311
+ };
312
+ }
313
+
314
+ const errors: ValidationError[] = [];
315
+
316
+ // CRITICAL: Negative validation - must be < 0
317
+ if (value >= 0) {
318
+ errors.push({
319
+ code: ErrorCode.NOT_NEGATIVE,
320
+ message: "Number must be negative",
321
+ path: [],
322
+ expected: "negative",
323
+ received: value,
324
+ receivedType: "number",
325
+ });
326
+ }
327
+
328
+ if (min !== undefined && value < min) {
329
+ errors.push({
330
+ code: ErrorCode.NUMBER_TOO_SMALL,
331
+ message: `Number must be at least ${min}`,
332
+ path: [],
333
+ expected: `negative(min: ${min})`,
334
+ received: value,
335
+ receivedType: "number",
336
+ });
337
+ }
338
+
339
+ if (max !== undefined && value > max) {
340
+ errors.push({
341
+ code: ErrorCode.NUMBER_TOO_LARGE,
342
+ message: `Number must be at most ${max}`,
343
+ path: [],
344
+ expected: `negative(max: ${max})`,
345
+ received: value,
346
+ receivedType: "number",
347
+ });
348
+ }
349
+
350
+ if (errors.length > 0) {
351
+ return {
352
+ success: false,
353
+ errors,
354
+ warnings: [],
355
+ data: undefined,
356
+ };
357
+ }
358
+
359
+ return {
360
+ success: true,
361
+ errors: [],
362
+ warnings: [],
363
+ data: value,
364
+ };
365
+ };
366
+
367
+ (validator as any)._fieldType = `negative(${min || ""},${max || ""})`;
368
+ (validator as any)._isCompiled = true;
369
+ return validator as CompiledFieldValidator;
370
+ }
371
+
372
+ /**
373
+ * Precompile number field validators
374
+ */
375
+ static precompileNumber(
376
+ constraints: {
377
+ min?: number;
378
+ max?: number;
379
+ integer?: boolean;
380
+ strictlyPositive?: boolean;
381
+ strictlyNegative?: boolean;
382
+ } = {}
383
+ ): CompiledFieldValidator {
384
+ const { min, max, integer, strictlyPositive, strictlyNegative } =
385
+ constraints;
386
+
387
+ const validator = (value: any): SchemaValidationResult => {
388
+ // DEBUG: Add logging to see if validator is being called
389
+ // // console.log("🔍 precompileNumber validator executing:");
390
+ // // console.log(" - value:", value, "type:", typeof value);
391
+ // // console.log(
392
+ // " - constraints: strictlyPositive =",
393
+ // strictlyPositive,
394
+ // ", strictlyNegative =",
395
+ // strictlyNegative
396
+ // );
397
+
398
+ if (typeof value !== "number" || isNaN(value)) {
399
+ // // console.log(" - FAIL: not a number");
400
+ return {
401
+ success: false,
402
+ errors: [ErrorHandler.createTypeError([], "number", value)],
403
+ warnings: [],
404
+ data: undefined,
405
+ };
406
+ }
407
+
408
+ const errors: ValidationError[] = [];
409
+
410
+ if (integer && !Number.isInteger(value)) {
411
+ // // console.log(" - FAIL: not an integer");
412
+ errors.push({
413
+ code: ErrorCode.NOT_INTEGER,
414
+ message: "Number must be an integer",
415
+ path: [],
416
+ expected: "integer",
417
+ received: value,
418
+ receivedType: "number",
419
+ });
420
+ }
421
+
422
+ // CRITICAL FIX: Handle strict positive/negative validation
423
+ if (strictlyPositive && value <= 0) {
424
+ // console.log(" - FAIL: not strictly positive (value <= 0)");
425
+ errors.push({
426
+ code: ErrorCode.NOT_POSITIVE,
427
+ message: "Number must be positive",
428
+ path: [],
429
+ expected: "positive",
430
+ received: value,
431
+ receivedType: "number",
432
+ });
433
+ }
434
+
435
+ if (strictlyNegative && value >= 0) {
436
+ // console.log(" - FAIL: not strictly negative (value >= 0)");
437
+ errors.push({
438
+ code: ErrorCode.NOT_NEGATIVE,
439
+ message: "Number must be negative",
440
+ path: [],
441
+ expected: "negative",
442
+ received: value,
443
+ receivedType: "number",
444
+ });
445
+ }
446
+
447
+ if (min !== undefined && value < min) {
448
+ // console.log(" - FAIL: value < min");
449
+ errors.push({
450
+ code: ErrorCode.NUMBER_TOO_SMALL,
451
+ message: `Number must be at least ${min}`,
452
+ path: [],
453
+ expected: `number(min: ${min})`,
454
+ received: value,
455
+ receivedType: "number",
456
+ });
457
+ }
458
+
459
+ if (max !== undefined && value > max) {
460
+ // console.log(" - FAIL: value > max");
461
+ errors.push({
462
+ code: ErrorCode.NUMBER_TOO_LARGE,
463
+ message: `Number must be at most ${max}`,
464
+ path: [],
465
+ expected: `number(max: ${max})`,
466
+ received: value,
467
+ receivedType: "number",
468
+ });
469
+ }
470
+
471
+ if (errors.length > 0) {
472
+ // console.log(" - FINAL RESULT: FAIL with errors:", errors);
473
+ return {
474
+ success: false,
475
+ errors,
476
+ warnings: [],
477
+ data: undefined,
478
+ };
479
+ }
480
+
481
+ // console.log(" - FINAL RESULT: PASS");
482
+ return {
483
+ success: true,
484
+ errors: [],
485
+ warnings: [],
486
+ data: value,
487
+ };
488
+ };
489
+
490
+ (validator as any)._fieldType = `number(${min || ""},${max || ""})`;
491
+ (validator as any)._isCompiled = true;
492
+ return validator as CompiledFieldValidator;
493
+ }
494
+
495
+ /**
496
+ * Precompile boolean field validators
497
+ */
498
+ static precompileBoolean(): CompiledFieldValidator {
499
+ const validator = (value: any): SchemaValidationResult => {
500
+ if (typeof value === "boolean") {
501
+ return {
502
+ success: true,
503
+ errors: [],
504
+ warnings: [],
505
+ data: value,
506
+ };
507
+ }
508
+ return {
509
+ success: false,
510
+ errors: [ErrorHandler.createTypeError([], "boolean", value)],
511
+ warnings: [],
512
+ data: undefined,
513
+ };
514
+ };
515
+
516
+ (validator as any)._fieldType = "boolean";
517
+ (validator as any)._isCompiled = true;
518
+ return validator as CompiledFieldValidator;
519
+ }
520
+
521
+ /**
522
+ * Precompile array field validators
523
+ */
524
+ static precompileArray(
525
+ elementValidator: CompiledFieldValidator,
526
+ constraints: {
527
+ minLength?: number;
528
+ maxLength?: number;
529
+ unique?: boolean;
530
+ } = {}
531
+ ): CompiledFieldValidator {
532
+ const { minLength, maxLength, unique } = constraints;
533
+
534
+ const validator = (value: any): SchemaValidationResult => {
535
+ if (!Array.isArray(value)) {
536
+ return {
537
+ success: false,
538
+ errors: [ErrorHandler.createTypeError([], "array", value)],
539
+ warnings: [],
540
+ data: undefined,
541
+ };
542
+ }
543
+
544
+ const errors: ValidationError[] = [];
545
+
546
+ if (minLength !== undefined && value.length < minLength) {
547
+ errors.push({
548
+ code: ErrorCode.ARRAY_TOO_SHORT,
549
+ message: `Array must have at least ${minLength} elements`,
550
+ path: [],
551
+ expected: `array(minLength: ${minLength})`,
552
+ received: value,
553
+ receivedType: "array",
554
+ });
555
+ }
556
+
557
+ if (maxLength !== undefined && value.length > maxLength) {
558
+ errors.push({
559
+ code: ErrorCode.ARRAY_TOO_LONG,
560
+ message: `Array must have at most ${maxLength} elements`,
561
+ path: [],
562
+ expected: `array(maxLength: ${maxLength})`,
563
+ received: value,
564
+ receivedType: "array",
565
+ });
566
+ }
567
+
568
+ // Validate each element
569
+ const validatedArray: any[] = [];
570
+ for (let i = 0; i < value.length; i++) {
571
+ const elementResult = elementValidator(value[i]);
572
+ if (!elementResult.success) {
573
+ errors.push(
574
+ ...elementResult.errors.map((error) => ({
575
+ ...error,
576
+ path: [i.toString(), ...error.path],
577
+ }))
578
+ );
579
+ } else {
580
+ validatedArray.push(elementResult.data);
581
+ }
582
+ }
583
+
584
+ // Check uniqueness if required
585
+ if (unique && validatedArray.length > 0) {
586
+ const uniqueValues = new Set(
587
+ validatedArray.map((v) => JSON.stringify(v))
588
+ );
589
+ if (uniqueValues.size !== validatedArray.length) {
590
+ errors.push({
591
+ code: ErrorCode.ARRAY_VALUES_NOT_UNIQUE,
592
+ message: "Array elements must be unique",
593
+ path: [],
594
+ expected: "unique",
595
+ received: value,
596
+ receivedType: "array",
597
+ });
598
+ }
599
+ }
600
+
601
+ if (errors.length > 0) {
602
+ return {
603
+ success: false,
604
+ errors,
605
+ warnings: [],
606
+ data: undefined,
607
+ };
608
+ }
609
+
610
+ return {
611
+ success: true,
612
+ errors: [],
613
+ warnings: [],
614
+ data: validatedArray,
615
+ };
616
+ };
617
+
618
+ (validator as any)._fieldType = `${elementValidator._fieldType}[]`;
619
+ (validator as any)._isCompiled = true;
620
+ return validator as CompiledFieldValidator;
621
+ }
622
+
623
+ /**
624
+ * Precompile optional field validators
625
+ */
626
+ static precompileOptional(
627
+ baseValidator: CompiledFieldValidator,
628
+ defaultValue?: any
629
+ ): CompiledFieldValidator {
630
+ const validator = (value: any): SchemaValidationResult => {
631
+ if (value === undefined) {
632
+ return {
633
+ success: true,
634
+ errors: [],
635
+ warnings: [],
636
+ data: defaultValue,
637
+ };
638
+ }
639
+
640
+ return baseValidator(value);
641
+ };
642
+
643
+ (validator as any)._fieldType = `${baseValidator._fieldType}?`;
644
+ (validator as any)._isCompiled = true;
645
+ return validator as CompiledFieldValidator;
646
+ }
647
+
648
+ /**
649
+ * Precompile constant field validators
650
+ */
651
+ static precompileConstant(constantValue: any): CompiledFieldValidator {
652
+ const stringValue = String(constantValue);
653
+
654
+ const validator = (value: any): SchemaValidationResult => {
655
+ if (value === constantValue || String(value) === stringValue) {
656
+ return {
657
+ success: true,
658
+ errors: [],
659
+ warnings: [],
660
+ data: constantValue,
661
+ };
662
+ }
663
+
664
+ return {
665
+ success: false,
666
+ errors: [
667
+ ErrorHandler.createConstantError(
668
+ [],
669
+ "constant",
670
+ value,
671
+ constantValue
672
+ ),
673
+ ],
674
+ warnings: [],
675
+ data: undefined,
676
+ };
677
+ };
678
+
679
+ (validator as any)._fieldType = `=${constantValue}`;
680
+ (validator as any)._isCompiled = true;
681
+ return validator as CompiledFieldValidator;
682
+ }
683
+
684
+ /**
685
+ * Precompile record field types (record<string, number>, Record<string, any>, etc.)
686
+ */
687
+ static precompileRecord(recordType: string): CompiledFieldValidator {
688
+ const validator = (value: any): SchemaValidationResult => {
689
+ // Use ValidationHelpers.validateRecordType for proper record validation
690
+ return ValidationHelpers.validateRecordType(
691
+ recordType,
692
+ value,
693
+ (fieldType: string, value: any) => {
694
+ // Recursively validate nested field types using the same precompiler system
695
+ const nestedValidator = FieldPrecompilers.parseAndCompile(fieldType);
696
+ return nestedValidator(value);
697
+ }
698
+ );
699
+ };
700
+
701
+ (validator as any)._fieldType = recordType;
702
+ (validator as any)._isCompiled = true;
703
+ return validator as CompiledFieldValidator;
704
+ }
705
+
706
+ /**
707
+ * Precompile special field types (email, url, json, etc.)
708
+ */
709
+ static precompileSpecialType(type: string): CompiledFieldValidator {
710
+ const validator = (value: any): SchemaValidationResult => {
711
+ // CRITICAL FIX: Parse constraints from the type string for proper validation
712
+
713
+ const parsed = ConstraintParser.parseConstraints(type);
714
+
715
+ // Use the imported ValidationHelpers with proper constraints
716
+ return ValidationHelpers.routeTypeValidation(
717
+ parsed.type,
718
+ value,
719
+ { ...parsed.constraints },
720
+ parsed.constraints
721
+ );
722
+ };
723
+
724
+ (validator as any)._fieldType = type;
725
+ (validator as any)._isCompiled = true;
726
+ return validator as CompiledFieldValidator;
727
+ }
728
+
729
+ /**
730
+ * Parse field type and create appropriate precompiled validator
731
+ */
732
+ static parseAndCompile(fieldType: string): CompiledFieldValidator {
733
+ // Handle optional fields
734
+ const isOptional = fieldType.endsWith("?");
735
+ const baseType = isOptional ? fieldType.slice(0, -1) : fieldType;
736
+
737
+ // Handle constants
738
+ if (baseType.startsWith("=")) {
739
+ const constantValue = baseType.slice(1);
740
+ const validator = this.precompileConstant(constantValue);
741
+ return isOptional ? this.precompileOptional(validator) : validator;
742
+ }
743
+
744
+ // Handle unions
745
+ if (baseType.includes("|")) {
746
+ const validator = this.precompileUnion(baseType);
747
+ return isOptional ? this.precompileOptional(validator) : validator;
748
+ }
749
+
750
+ // Handle arrays
751
+ if (baseType.endsWith("[]")) {
752
+ const elementType = baseType.slice(0, -2);
753
+ const elementValidator = this.parseAndCompile(elementType);
754
+ const validator = this.precompileArray(elementValidator);
755
+ return isOptional ? this.precompileOptional(validator) : validator;
756
+ }
757
+
758
+ // Handle record types (record<string, number>, Record<string, any>, etc.)
759
+ if (
760
+ (baseType.startsWith("record<") && baseType.endsWith(">")) ||
761
+ (baseType.startsWith("Record<") && baseType.endsWith(">"))
762
+ ) {
763
+ const validator = this.precompileRecord(baseType);
764
+ return isOptional ? this.precompileOptional(validator) : validator;
765
+ }
766
+
767
+ // Handle basic types with constraints (including URL args like url.https)
768
+ const constraintMatch = baseType.match(/^([\w.]+)(?:\(([^)]*)\))?$/);
769
+ if (constraintMatch) {
770
+ const [, type, constraintsStr] = constraintMatch;
771
+
772
+ switch (type) {
773
+ case "string":
774
+ const stringConstraints = this.parseStringConstraints(constraintsStr);
775
+ const stringValidator = this.precompileString(stringConstraints);
776
+ return isOptional
777
+ ? this.precompileOptional(stringValidator)
778
+ : stringValidator;
779
+
780
+ case "number":
781
+ case "int":
782
+ case "integer":
783
+ case "float":
784
+ const numberConstraints = this.parseNumberConstraints(
785
+ constraintsStr,
786
+ type
787
+ );
788
+ const numberValidator = this.precompileNumber(numberConstraints);
789
+ return isOptional
790
+ ? this.precompileOptional(numberValidator)
791
+ : numberValidator;
792
+
793
+ case "positive":
794
+ // CRITICAL FIX: Handle positive numbers with proper validation
795
+ const positiveConstraints = this.parseNumberConstraints(
796
+ constraintsStr,
797
+ type
798
+ );
799
+ const positiveValidator =
800
+ this.precompilePositiveNumber(positiveConstraints);
801
+ return isOptional
802
+ ? this.precompileOptional(positiveValidator)
803
+ : positiveValidator;
804
+
805
+ case "negative":
806
+ // CRITICAL FIX: Handle negative numbers with proper validation
807
+ const negativeConstraints = this.parseNumberConstraints(
808
+ constraintsStr,
809
+ type
810
+ );
811
+ const negativeValidator =
812
+ this.precompileNegativeNumber(negativeConstraints);
813
+ return isOptional
814
+ ? this.precompileOptional(negativeValidator)
815
+ : negativeValidator;
816
+
817
+ case "double":
818
+ // CRITICAL FIX: Handle double with float constraints to match ValidationHelpers routing
819
+ const doubleConstraints = this.parseNumberConstraints(
820
+ constraintsStr,
821
+ type
822
+ );
823
+ const doubleValidator = this.precompileFloat(doubleConstraints);
824
+ return isOptional
825
+ ? this.precompileOptional(doubleValidator)
826
+ : doubleValidator;
827
+
828
+ case "boolean":
829
+ case "bool":
830
+ const boolValidator = this.precompileBoolean();
831
+ return isOptional
832
+ ? this.precompileOptional(boolValidator)
833
+ : boolValidator;
834
+
835
+ // Handle new field types by delegating to ValidationHelpers
836
+ case "json":
837
+ case "ip":
838
+ case "password":
839
+ case "text":
840
+ case "object":
841
+ case "url":
842
+ case "email":
843
+ case "uuid":
844
+ case "phone":
845
+ case "slug":
846
+ case "username":
847
+ case "hexcolor":
848
+ case "base64":
849
+ case "jwt":
850
+ case "semver":
851
+ case "date":
852
+ case "any":
853
+ const specialValidator = this.precompileSpecialType(type);
854
+ return isOptional
855
+ ? this.precompileOptional(specialValidator)
856
+ : specialValidator;
857
+
858
+ default:
859
+ // Check if it's a URL arg (url.https, url.http, etc.)
860
+ if (type.startsWith("url.")) {
861
+ const urlArgValidator = this.precompileSpecialType(type);
862
+ return isOptional
863
+ ? this.precompileOptional(urlArgValidator)
864
+ : urlArgValidator;
865
+ }
866
+
867
+ // Fallback for unknown types
868
+ return this.createFallbackValidator(fieldType);
869
+ }
870
+ }
871
+
872
+ return this.createFallbackValidator(fieldType);
873
+ }
874
+
875
+ private static parseStringConstraints(constraintsStr?: string): {
876
+ minLength?: number;
877
+ maxLength?: number;
878
+ pattern?: RegExp;
879
+ } {
880
+ if (!constraintsStr) return {};
881
+
882
+ // CRITICAL FIX: Use ConstraintParser to properly handle regex patterns
883
+ const ConstraintParser =
884
+ require("../validators/ConstraintParser").ConstraintParser;
885
+
886
+ try {
887
+ // Parse the full constraint string using the proper parser
888
+ const fullType = `string(${constraintsStr})`;
889
+ const parsed = ConstraintParser.parseConstraints(fullType);
890
+
891
+ // Extract the constraints we need
892
+ const constraints: any = {};
893
+
894
+ if (parsed.constraints.minLength !== undefined) {
895
+ constraints.minLength = parsed.constraints.minLength;
896
+ }
897
+ if (parsed.constraints.maxLength !== undefined) {
898
+ constraints.maxLength = parsed.constraints.maxLength;
899
+ }
900
+ if (parsed.constraints.pattern) {
901
+ constraints.pattern = parsed.constraints.pattern;
902
+ }
903
+
904
+ return constraints;
905
+ } catch (error) {
906
+ // Fallback to simple parsing for backward compatibility
907
+ const parts = constraintsStr.split(",");
908
+ const constraints: any = {};
909
+
910
+ if (parts[0] && parts[0].trim()) {
911
+ constraints.minLength = parseInt(parts[0].trim());
912
+ }
913
+ if (parts[1] && parts[1].trim()) {
914
+ constraints.maxLength = parseInt(parts[1].trim());
915
+ }
916
+
917
+ return constraints;
918
+ }
919
+ }
920
+
921
+ private static parseNumberConstraints(
922
+ constraintsStr?: string,
923
+ type?: string
924
+ ): { min?: number; max?: number; integer?: boolean } {
925
+ const constraints: any = {};
926
+
927
+ if (type === "int" || type === "integer") {
928
+ constraints.integer = true;
929
+ }
930
+ // NOTE: positive and negative types are now handled by separate precompilers
931
+ // No need to set special constraints here
932
+
933
+ if (constraintsStr) {
934
+ const parts = constraintsStr.split(",");
935
+ if (parts[0] && parts[0].trim()) {
936
+ constraints.min = parseFloat(parts[0].trim());
937
+ }
938
+ if (parts[1] && parts[1].trim()) {
939
+ constraints.max = parseFloat(parts[1].trim());
940
+ }
941
+ }
942
+ return constraints;
943
+ }
944
+
945
+ private static createFallbackValidator(
946
+ fieldType: string
947
+ ): CompiledFieldValidator {
948
+ const validator = (value: any): SchemaValidationResult => {
949
+ // Basic fallback validation
950
+ return {
951
+ success: true,
952
+ errors: [],
953
+ warnings: [`Fallback validation used for type: ${fieldType}`],
954
+ data: value,
955
+ };
956
+ };
957
+
958
+ (validator as any)._fieldType = fieldType;
959
+ (validator as any)._isCompiled = true;
960
+ return validator as CompiledFieldValidator;
961
+ }
962
+ }