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,829 @@
1
+ # Field Types Reference
2
+
3
+ Complete guide to all field types available in ReliantType, with examples and constraints.
4
+
5
+ ## 📚 Table of Contents
6
+
7
+ - [Basic Types](#basic-types)
8
+ - [Constrained Types](#constrained-types)
9
+ - [Format Validation](#format-validation)
10
+ - [Array Types](#array-types)
11
+ - [Union Types](#union-types)
12
+ - [Optional Types](#optional-types)
13
+ - [Literal Values](#literal-values)
14
+ - [Custom Patterns](#custom-patterns)
15
+ - [Special Types](#special-types)
16
+
17
+ ## Basic Types
18
+
19
+ ### String Type
20
+
21
+ ```typescript
22
+ const StringSchema = Interface({
23
+ // Basic string
24
+ name: "string",
25
+
26
+ // String with length constraints
27
+ username: "string(3,20)", // 3-20 characters
28
+ password: "string(8,)", // Minimum 8 characters
29
+ code: "string(6,6)", // Exactly 6 characters
30
+ description: "string(,500)", // Maximum 500 characters
31
+
32
+ // Optional string
33
+ nickname: "string?",
34
+ bio: "string(,200)?",
35
+ });
36
+ ```
37
+
38
+ **Constraint Syntax:**
39
+
40
+ - `string(min,max)` - Length between min and max
41
+ - `string(min,)` - Minimum length
42
+ - `string(,max)` - Maximum length
43
+ - `string(exact,exact)` - Exact length
44
+
45
+ ### Number Type
46
+
47
+ ```typescript
48
+ const NumberSchema = Interface({
49
+ // Basic number
50
+ age: "number",
51
+
52
+ // Number with range constraints
53
+ score: "number(0,100)", // Range 0-100
54
+ price: "number(0.01,)", // Minimum 0.01
55
+ discount: "number(,1.0)", // Maximum 1.0
56
+ temperature: "number(-273.15,)", // Absolute zero minimum
57
+
58
+ // Integer constraints
59
+ count: "int", // Integer only
60
+ positiveInt: "int(1,)", // Positive integer
61
+ limitedInt: "int(0,1000)", // Integer range
62
+
63
+ // Positive/negative shortcuts
64
+ id: "positive", // Positive number
65
+ debt: "negative", // Negative number
66
+
67
+ // Optional number
68
+ rating: "number(1,5)?",
69
+ });
70
+ ```
71
+
72
+ **Constraint Syntax:**
73
+
74
+ - `number(min,max)` - Range between min and max
75
+ - `int` - Integer validation
76
+ - `positive` - Positive number (> 0)
77
+ - `negative` - Negative number (< 0)
78
+
79
+ ### Boolean Type
80
+
81
+ ```typescript
82
+ const BooleanSchema = Interface({
83
+ // Basic boolean
84
+ isActive: "boolean",
85
+
86
+ // Optional boolean
87
+ isVerified: "boolean?",
88
+
89
+ // Boolean with smart conversion (strings "true"/"false")
90
+ enableFeature: "boolean",
91
+ });
92
+ ```
93
+
94
+ ### Date Type
95
+
96
+ ```typescript
97
+ const DateSchema = Interface({
98
+ // Basic date
99
+ createdAt: "date",
100
+
101
+ // Optional date
102
+ updatedAt: "date?",
103
+ lastLogin: "date?",
104
+
105
+ // Date validation accepts:
106
+ // - Date objects
107
+ // - ISO date strings
108
+ // - Unix timestamps (numbers)
109
+ birthday: "date",
110
+ expiresAt: "date",
111
+ });
112
+ ```
113
+
114
+ ## Constrained Types
115
+
116
+ ### String Constraints
117
+
118
+ ```typescript
119
+ const StringConstraintsSchema = Interface({
120
+ // Length constraints
121
+ shortCode: "string(2,5)", // 2-5 characters
122
+ longText: "string(100,)", // Minimum 100 characters
123
+ tweet: "string(,280)", // Maximum 280 characters
124
+
125
+ // Exact length
126
+ countryCode: "string(2,2)", // Exactly 2 characters
127
+ zipCode: "string(5,5)", // Exactly 5 characters
128
+
129
+ // Combined with optional
130
+ optionalCode: "string(3,10)?", // Optional, 3-10 chars if present
131
+ });
132
+ ```
133
+
134
+ ### Number Constraints
135
+
136
+ ```typescript
137
+ const NumberConstraintsSchema = Interface({
138
+ // Range constraints
139
+ percentage: "number(0,100)", // 0-100
140
+ probability: "number(0,1)", // 0-1
141
+ temperature: "number(-50,50)", // -50 to 50
142
+
143
+ // Open ranges
144
+ minimumAge: "number(18,)", // 18 or higher
145
+ maxDiscount: "number(,0.5)", // 0.5 or lower
146
+
147
+ // Integer constraints
148
+ pageNumber: "int(1,)", // Positive integer
149
+ itemCount: "int(0,1000)", // 0-1000 integer
150
+
151
+ // Special number types
152
+ userId: "positive", // Any positive number
153
+ balance: "number", // Any number (can be negative)
154
+ });
155
+ ```
156
+
157
+ ### Array Constraints
158
+
159
+ ```typescript
160
+ const ArrayConstraintsSchema = Interface({
161
+ // Basic arrays
162
+ tags: "string[]", // Array of strings
163
+ scores: "number[]", // Array of numbers
164
+ flags: "boolean[]", // Array of booleans
165
+
166
+ // Array size constraints
167
+ limitedTags: "string[](1,5)", // 1-5 items
168
+ minItems: "string[](2,)", // Minimum 2 items
169
+ maxItems: "string[](,10)", // Maximum 10 items
170
+ exactItems: "string[](3,3)", // Exactly 3 items
171
+
172
+ // Optional arrays
173
+ optionalTags: "string[]?", // Optional array
174
+ limitedOptional: "string[](1,5)?", // Optional, 1-5 items if present
175
+
176
+ // Nested constraints
177
+ usernames: "string(3,20)[](1,100)", // Array of 3-20 char strings, 1-100 items
178
+ ages: "int(0,120)[](,50)", // Array of 0-120 integers, max 50 items
179
+ });
180
+ ```
181
+
182
+ ## Format Validation
183
+
184
+ ### Built-in Formats
185
+
186
+ ```typescript
187
+ const FormatSchema = Interface({
188
+ // Email validation
189
+ email: "email",
190
+ workEmail: "email?",
191
+
192
+ // URL validation
193
+ website: "url",
194
+ avatar: "url?",
195
+
196
+ // UUID validation
197
+ id: "uuid",
198
+ sessionId: "uuid?",
199
+
200
+ // Phone validation (international format)
201
+ phone: "phone",
202
+ mobile: "phone?",
203
+
204
+ // IP address validation
205
+ serverIp: "ip",
206
+ clientIp: "ip?",
207
+
208
+ // JSON validation
209
+ config: "json",
210
+ metadata: "json?",
211
+
212
+ // Hex color validation
213
+ primaryColor: "hexcolor",
214
+ accentColor: "hexcolor?",
215
+
216
+ // Base64 validation
217
+ encodedData: "base64",
218
+ attachment: "base64?",
219
+
220
+ // JWT validation
221
+ authToken: "jwt",
222
+ refreshToken: "jwt?",
223
+
224
+ // Semantic version validation
225
+ appVersion: "semver",
226
+ minVersion: "semver?",
227
+ });
228
+ ```
229
+
230
+ ### URL Validation with Arguments
231
+
232
+ ReliantType provides powerful URL validation with specialized arguments for different use cases. Each URL argument enforces specific protocol and security restrictions.
233
+
234
+ #### Available URL Arguments
235
+
236
+ ```typescript
237
+ const UrlSchema = Interface({
238
+ // Basic URL validation (defaults to web protocols)
239
+ website: "url",
240
+
241
+ // HTTPS-only validation (most secure)
242
+ secureApi: "url.https",
243
+ paymentGateway: "url.https",
244
+
245
+ // HTTP-only validation
246
+ legacyEndpoint: "url.http",
247
+
248
+ // Web protocols (HTTP + HTTPS)
249
+ publicWebsite: "url.web",
250
+
251
+ // Development mode (permissive for localhost/IPs)
252
+ devServer: "url.dev",
253
+ localApi: "url.dev",
254
+
255
+ // FTP-only validation
256
+ fileServer: "url.ftp",
257
+ backupLocation: "url.ftp",
258
+
259
+ // Optional URL arguments
260
+ optionalWebsite: "url.https?",
261
+ optionalApi: "url.web?",
262
+
263
+ // URL arrays with arguments
264
+ apiEndpoints: "url.https[]",
265
+ devServers: "url.dev[](1,5)",
266
+ });
267
+ ```
268
+
269
+ #### URL Argument Specifications
270
+
271
+ | Argument | Protocols | Localhost | Private IPs | Use Case |
272
+ | ----------- | ----------- | --------- | ----------- | --------------------- |
273
+ | `url` | HTTP, HTTPS | ❌ | ❌ | General web URLs |
274
+ | `url.https` | HTTPS only | ❌ | ❌ | Secure APIs, payments |
275
+ | `url.http` | HTTP only | ❌ | ❌ | Legacy systems |
276
+ | `url.web` | HTTP, HTTPS | ❌ | ❌ | Public websites |
277
+ | `url.dev` | HTTP, HTTPS | ✅ | ✅ | Development/testing |
278
+ | `url.ftp` | FTP only | ❌ | ❌ | File transfers |
279
+
280
+ #### Security Features
281
+
282
+ ```typescript
283
+ const SecurityExamples = Interface({
284
+ // ✅ HTTPS-only - blocks HTTP, localhost, IPs
285
+ securePayment: "url.https",
286
+ // Valid: "https://api.stripe.com/v1/charges"
287
+ // Invalid: "http://api.stripe.com", "https://localhost:3000"
288
+
289
+ // ✅ Development mode - allows localhost and IPs
290
+ devEnvironment: "url.dev",
291
+ // Valid: "http://localhost:3000", "https://192.168.1.100:8080"
292
+ // Invalid: "ftp://files.example.com"
293
+
294
+ // ✅ Web protocols - production-ready validation
295
+ publicApi: "url.web",
296
+ // Valid: "https://api.example.com", "http://legacy.example.com"
297
+ // Invalid: "ftp://files.com", "https://localhost:3000"
298
+ });
299
+ ```
300
+
301
+ #### Error Handling for Invalid Arguments
302
+
303
+ ```typescript
304
+ // ❌ Invalid URL arguments throw clear errors
305
+ try {
306
+ const InvalidSchema = Interface({
307
+ badUrl: "url.invalid", // Invalid argument
308
+ });
309
+ } catch (error) {
310
+ console.log(error.message);
311
+ // "Invalid URL argument: url.invalid. Valid arguments are: url.https, url.http, url.web, url.dev, url.ftp"
312
+ }
313
+
314
+ // ❌ Case-sensitive validation
315
+ try {
316
+ const CaseSchema = Interface({
317
+ badCase: "URL.HTTPS", // Wrong case
318
+ });
319
+ } catch (error) {
320
+ console.log("URL arguments are case-sensitive");
321
+ }
322
+ ```
323
+
324
+ #### Real-World Examples
325
+
326
+ ```typescript
327
+ const ECommerceSchema = Interface({
328
+ // Payment processing (HTTPS required)
329
+ paymentWebhook: "url.https",
330
+ stripeEndpoint: "url.https",
331
+
332
+ // Public website URLs
333
+ companyWebsite: "url.web",
334
+ socialMediaLinks: "url.web[]?",
335
+
336
+ // Development configuration
337
+ devApiUrl: "url.dev",
338
+ testingEndpoints: "url.dev[](1,10)",
339
+
340
+ // File storage
341
+ ftpBackupServer: "url.ftp",
342
+ assetCdnUrls: "url.https[]",
343
+ });
344
+
345
+ const MicroserviceSchema = Interface({
346
+ // Service discovery
347
+ authService: "url.https",
348
+ userService: "url.https",
349
+
350
+ // Internal communication (dev environment)
351
+ internalServices: "url.dev[]",
352
+
353
+ // External integrations
354
+ thirdPartyApis: "url.https[]",
355
+ webhookUrls: "url.https[](1,5)",
356
+ });
357
+ ```
358
+
359
+ ### Advanced Format Types
360
+
361
+ #### Hex Color Validation
362
+
363
+ ```typescript
364
+ const ColorSchema = Interface({
365
+ // Basic hex colors
366
+ primaryColor: "hexcolor", // #RGB, #RRGGBB, #RRGGBBAA
367
+ secondaryColor: "hexcolor?", // Optional color
368
+
369
+ // Color arrays
370
+ palette: "hexcolor[]", // Array of colors
371
+ gradientColors: "hexcolor[](2,10)", // 2-10 colors
372
+
373
+ // Examples of valid values:
374
+ // "#F00", "#FF0000", "#FF0000FF"
375
+ // "#abc", "#ABCDEF", "#12345678"
376
+ });
377
+ ```
378
+
379
+ #### Base64 Validation
380
+
381
+ ```typescript
382
+ const DataSchema = Interface({
383
+ // Basic Base64
384
+ encodedData: "base64",
385
+ attachment: "base64?",
386
+
387
+ // Base64 arrays
388
+ files: "base64[]",
389
+ images: "base64[](1,5)",
390
+
391
+ // Examples of valid values:
392
+ // "SGVsbG8gV29ybGQ="
393
+ // "VGhpcyBpcyBhIHRlc3Q="
394
+ });
395
+ ```
396
+
397
+ #### JWT (JSON Web Token) Validation
398
+
399
+ ```typescript
400
+ const AuthSchema = Interface({
401
+ // JWT tokens
402
+ accessToken: "jwt",
403
+ refreshToken: "jwt?",
404
+
405
+ // JWT arrays
406
+ tokens: "jwt[]",
407
+ sessionTokens: "jwt[](1,3)",
408
+
409
+ // Examples of valid values:
410
+ // "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
411
+ });
412
+ ```
413
+
414
+ #### Semantic Version (SemVer) Validation
415
+
416
+ ```typescript
417
+ const VersionSchema = Interface({
418
+ // Semantic versions
419
+ appVersion: "semver",
420
+ minVersion: "semver?",
421
+
422
+ // Version arrays
423
+ supportedVersions: "semver[]",
424
+ compatibleVersions: "semver[](1,10)",
425
+
426
+ // Examples of valid values:
427
+ // "1.0.0", "2.1.3", "1.0.0-alpha.1"
428
+ // "1.2.3-beta.4+build.5"
429
+ });
430
+ ```
431
+
432
+ ### Custom Regex Patterns
433
+
434
+ ```typescript
435
+ const RegexSchema = Interface({
436
+ // US ZIP code
437
+ zipCode: "string(/^\\d{5}(-\\d{4})?$/)",
438
+
439
+ // Product code (2 letters + 4 digits)
440
+ productCode: "string(/^[A-Z]{2}\\d{4}$/)",
441
+
442
+ // Username (alphanumeric + underscore, 3-20 chars)
443
+ username: "string(/^[a-zA-Z0-9_]{3,20}$/)",
444
+
445
+ // Hex color code
446
+ color: "string(/^#[0-9A-Fa-f]{6}$/)",
447
+
448
+ // Credit card number (basic format)
449
+ creditCard: "string(/^\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}[\\s-]?\\d{4}$/)",
450
+
451
+ // ISO country code
452
+ country: "string(/^[A-Z]{2}$/)",
453
+
454
+ // Semantic version
455
+ version: "string(/^\\d+\\.\\d+\\.\\d+$/)",
456
+
457
+ // Optional regex patterns
458
+ optionalCode: "string(/^[A-Z]{3}\\d{3}$/)?",
459
+ });
460
+ ```
461
+
462
+ ## Array Types
463
+
464
+ ### Basic Arrays
465
+
466
+ ```typescript
467
+ const ArraySchema = Interface({
468
+ // Simple arrays
469
+ tags: "string[]",
470
+ scores: "number[]",
471
+ active: "boolean[]",
472
+ dates: "date[]",
473
+
474
+ // Optional arrays
475
+ categories: "string[]?",
476
+ ratings: "number[]?",
477
+
478
+ // Empty arrays allowed by default
479
+ emptyAllowed: "string[]", // Can be []
480
+ });
481
+ ```
482
+
483
+ ### Constrained Arrays
484
+
485
+ ```typescript
486
+ const ConstrainedArraySchema = Interface({
487
+ // Size constraints
488
+ requiredTags: "string[](1,)", // At least 1 item
489
+ limitedTags: "string[](1,10)", // 1-10 items
490
+ maxTags: "string[](,5)", // Maximum 5 items
491
+ exactTags: "string[](3,3)", // Exactly 3 items
492
+
493
+ // Element constraints with array constraints
494
+ usernames: "string(3,20)[](1,100)", // 1-100 usernames, each 3-20 chars
495
+ ages: "int(0,120)[](,50)", // Max 50 ages, each 0-120
496
+ emails: "email[](1,10)", // 1-10 email addresses
497
+ urls: "url[](,5)", // Max 5 URLs
498
+
499
+ // Complex nested constraints
500
+ productCodes: "string(/^[A-Z]{2}\\d{4}$/)[](1,)", // At least 1 valid product code
501
+ });
502
+ ```
503
+
504
+ ### Nested Arrays
505
+
506
+ ```typescript
507
+ const NestedArraySchema = Interface({
508
+ // Array of objects
509
+ users: {
510
+ id: "uuid",
511
+ name: "string",
512
+ email: "email"
513
+ }[],
514
+
515
+ // Array of arrays
516
+ matrix: "number[][]",
517
+ coordinates: "number[](2,2)[]", // Array of coordinate pairs
518
+
519
+ // Optional nested arrays
520
+ optionalMatrix: "number[][]?",
521
+ groups: "string[][]?"
522
+ });
523
+ ```
524
+
525
+ ## Union Types
526
+
527
+ ### Basic Unions
528
+
529
+ ```typescript
530
+ const UnionSchema = Interface({
531
+ // String unions
532
+ status: "active|inactive|pending",
533
+ role: "admin|user|guest|moderator",
534
+ theme: "light|dark|auto",
535
+
536
+ // Number unions
537
+ priority: "1|2|3|4|5",
538
+ version: "1.0|2.0|3.0",
539
+
540
+ // Mixed type unions
541
+ id: "string|number",
542
+ value: "string|number|boolean",
543
+
544
+ // Optional unions
545
+ optionalStatus: "active|inactive?",
546
+ optionalValue: "string|number?",
547
+ });
548
+ ```
549
+
550
+ ### Complex Unions
551
+
552
+ ```typescript
553
+ const ComplexUnionSchema = Interface({
554
+ // Union with constraints
555
+ identifier: "string(3,)|number(1,)", // String 3+ chars OR number 1+
556
+
557
+ // Union with formats
558
+ contact: "email|phone", // Email OR phone number
559
+
560
+ // Union with arrays
561
+ data: "string[]|number[]", // Array of strings OR numbers
562
+
563
+ // Union with regex
564
+ code: "string(/^[A-Z]{3}$/)|string(/^\\d{6}$/)", // 3 letters OR 6 digits
565
+
566
+ // Nested unions in objects
567
+ config: {
568
+ mode: "development|staging|production",
569
+ debug: "boolean|string",
570
+ port: "number|string",
571
+ },
572
+ });
573
+ ```
574
+
575
+ ## Optional Types
576
+
577
+ ### Basic Optional
578
+
579
+ ```typescript
580
+ import { NehoID as ID } from "nehoid";
581
+
582
+ const OptionalSchema = Interface({
583
+ // Required fields
584
+ id: "uuid",
585
+ name: "string",
586
+
587
+ // Optional fields (can be undefined)
588
+ nickname: "string?",
589
+ bio: "string?",
590
+ avatar: "url?",
591
+
592
+ // Optional with constraints
593
+ age: "number(0,120)?",
594
+ tags: "string[](1,10)?",
595
+
596
+ // Optional nested objects
597
+ profile: {
598
+ firstName: "string?",
599
+ lastName: "string",
600
+ middleName: "string?", // Optional within nested object
601
+ },
602
+ });
603
+
604
+ const profile = {
605
+ lastName: "Eleazar",
606
+ };
607
+
608
+ const result = OptionalSchema.safeParse({
609
+ id: ID.uuid(),
610
+ age: 1000,
611
+ name: "Seth",
612
+ profile,
613
+ });
614
+
615
+ if (result.success) {
616
+ console.log("✅ Expected success:", result.data);
617
+ } else {
618
+ console.log("❌ Unexpected errors:", result.errors);
619
+ }
620
+ ```
621
+
622
+ ### Optional vs Nullable
623
+
624
+ ```typescript
625
+ const OptionalVsNullableSchema = Interface({
626
+ // Optional - can be undefined, not present in object
627
+ optionalField: "string?",
628
+
629
+ // Nullable - must be present, can be null
630
+ nullableField: "string|null",
631
+
632
+ // Both optional and nullable
633
+ flexibleField: "string|null?",
634
+
635
+ // Array variations
636
+ optionalArray: "string[]?", // Array can be undefined
637
+ nullableArray: "string[]|null", // Array can be null
638
+ arrayOfOptional: "string?[]", // Array of optional strings
639
+ });
640
+ ```
641
+
642
+ ## Literal Values
643
+
644
+ ### Constant Values
645
+
646
+ ```typescript
647
+ const LiteralSchema = Interface({
648
+ // String literals
649
+ type: "=user", // Must be exactly "user"
650
+ version: "=2.0", // Must be exactly "2.0"
651
+
652
+ // Number literals
653
+ apiVersion: "=1", // Must be exactly 1
654
+ maxRetries: "=3", // Must be exactly 3
655
+
656
+ // Boolean literals
657
+ isEnabled: "=true", // Must be exactly true
658
+ isLegacy: "=false", // Must be exactly false
659
+
660
+ // Complex literals
661
+ config: '={"theme":"dark"}', // Must be exact object
662
+ tags: '=["default","user"]', // Must be exact array
663
+
664
+ // Optional literals
665
+ optionalType: "=admin?", // Optional, but if present must be "admin"
666
+ });
667
+ ```
668
+
669
+ ## Custom Patterns
670
+
671
+ ### Advanced Regex
672
+
673
+ ```typescript
674
+ const AdvancedPatternSchema = Interface({
675
+ // Complex email pattern
676
+ corporateEmail: "string(/^[a-zA-Z0-9._%+-]+@company\\.com$/)",
677
+
678
+ // Strong password pattern
679
+ strongPassword:
680
+ "string(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,}$/)",
681
+
682
+ // International phone
683
+ internationalPhone: "string(/^\\+[1-9]\\d{1,14}$/)",
684
+
685
+ // Social security number
686
+ ssn: "string(/^\\d{3}-\\d{2}-\\d{4}$/)",
687
+
688
+ // License plate (US format)
689
+ licensePlate: "string(/^[A-Z]{1,3}[0-9]{1,4}$/)",
690
+
691
+ // MAC address
692
+ macAddress: "string(/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/)",
693
+
694
+ // IP address
695
+ ipv4: "ip", // or use a custom patterns
696
+
697
+ //JWT token validation
698
+ isJWT: "jwt", // or custom can be also use
699
+
700
+ //sem version
701
+ version: "semver" // custom could be use
702
+
703
+ //b64 test
704
+ isB64: "base64", // use custom if you want
705
+
706
+ //json test
707
+ isJson: "json",
708
+
709
+ //hexcolor validation
710
+ isHexC: "hexcolor", // use custom if want
711
+
712
+ // Credit card (Luhn algorithm not included)
713
+ creditCardNumber:
714
+ "string(/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13})$/)",
715
+ });
716
+ ```
717
+
718
+ ## Special Types
719
+
720
+ ### Any Type
721
+
722
+ ```typescript
723
+ const AnyTypeSchema = Interface({
724
+ // Any type (use sparingly)
725
+ metadata: "any",
726
+ config: "any?",
727
+
728
+ // Better alternatives when possible
729
+ stringOrNumber: "string|number", // Prefer unions
730
+ jsonData: "json", // Prefer JSON validation
731
+
732
+ // Any in arrays
733
+ mixedArray: "any[]",
734
+ optionalMixed: "any[]?",
735
+ });
736
+ ```
737
+
738
+ ### Nested Objects
739
+
740
+ ```typescript
741
+ const NestedSchema = Interface({
742
+ user: {
743
+ id: "uuid",
744
+ profile: {
745
+ name: "string",
746
+ contact: {
747
+ email: "email",
748
+ phone: "phone?",
749
+ address: {
750
+ street: "string",
751
+ city: "string",
752
+ country: "string(2,2)",
753
+ zipCode: "string(/^\\d{5}(-\\d{4})?$/)"
754
+ }?
755
+ }
756
+ }
757
+ },
758
+
759
+ // Optional nested objects
760
+ settings: {
761
+ theme: "light|dark",
762
+ notifications: {
763
+ email: "boolean",
764
+ push: "boolean"
765
+ }
766
+ }?
767
+ });
768
+ ```
769
+
770
+ ## 🎯 Best Practices
771
+
772
+ ### Type Selection Guidelines
773
+
774
+ 1. **Use specific types over generic ones**
775
+
776
+ ```typescript
777
+ // ✅ Good
778
+ email: "email",
779
+ age: "int(0,120)",
780
+
781
+ // ❌ Avoid
782
+ email: "string",
783
+ age: "number"
784
+ ```
785
+
786
+ 2. **Prefer constraints over validation logic**
787
+
788
+ ```typescript
789
+ // ✅ Good
790
+ username: "string(3,20)",
791
+
792
+ // ❌ Avoid (handle in business logic instead)
793
+ username: "string"
794
+ ```
795
+
796
+ 3. **Use unions for known values**
797
+
798
+ ```typescript
799
+ // ✅ Good
800
+ status: "active|inactive|pending",
801
+
802
+ // ❌ Avoid
803
+ status: "string"
804
+ ```
805
+
806
+ 4. **Be explicit with optional fields**
807
+
808
+ ```typescript
809
+ // ✅ Good - clear intent
810
+ nickname: "string?",
811
+ bio: "string(,500)?",
812
+
813
+ // ❌ Unclear
814
+ nickname: "string|undefined"
815
+ ```
816
+
817
+ ### Performance Tips
818
+
819
+ 1. **Simple types are faster than complex regex**
820
+ 2. **Built-in formats are optimized**
821
+ 3. **Union types with fewer options perform better**
822
+ 4. **Array constraints are validated efficiently**
823
+
824
+ ## 🔗 Related Documentation
825
+
826
+ - **[Getting Started](./GETTING-STARTED.md)** - Basic usage and setup
827
+ - **[Conditional Validation](./CONDITIONAL-VALIDATION.md)** - Advanced business logic
828
+ - **[Examples Collection](./EXAMPLES.md)** - Real-world usage patterns
829
+ - **[Quick Reference](./QUICK-REFERENCE.md)** - Syntax cheat sheet