@maroonedog/luq 0.1.0-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (312) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +879 -0
  3. package/dist/constants.d.ts +27 -0
  4. package/dist/core/async.experimental/async-context.d.ts +60 -0
  5. package/dist/core/builder/array-batch-optimizer.d.ts +66 -0
  6. package/dist/core/builder/context/field-context.d.ts +31 -0
  7. package/dist/core/builder/context/field-type-detector.d.ts +19 -0
  8. package/dist/core/builder/core/builder.d.ts +10 -0
  9. package/dist/core/builder/core/field-builder.d.ts +13 -0
  10. package/dist/core/builder/core/index.d.ts +17 -0
  11. package/dist/core/builder/index.d.ts +24 -0
  12. package/dist/core/builder/nested-array-processor.d.ts +52 -0
  13. package/dist/core/builder/plugins/composable-conditional-plugin.d.ts +32 -0
  14. package/dist/core/builder/plugins/composable-directly-plugin.d.ts +32 -0
  15. package/dist/core/builder/plugins/composable-plugin.d.ts +242 -0
  16. package/dist/core/builder/plugins/plugin-creator.d.ts +38 -0
  17. package/dist/core/builder/plugins/plugin-interfaces.d.ts +343 -0
  18. package/dist/core/builder/plugins/plugin-types.d.ts +441 -0
  19. package/dist/core/builder/raw-validator.d.ts +22 -0
  20. package/dist/core/builder/types/field-options.d.ts +46 -0
  21. package/dist/core/builder/types/types.d.ts +318 -0
  22. package/dist/core/builder/ultra-fast-validator.d.ts +30 -0
  23. package/dist/core/builder/validator-factory.d.ts +29 -0
  24. package/dist/core/global-config.d.ts +27 -0
  25. package/dist/core/index.d.ts +36 -0
  26. package/dist/core/optimization/array-batch-validator.d.ts +68 -0
  27. package/dist/core/optimization/core/field-utils.d.ts +103 -0
  28. package/dist/core/optimization/core/strategy-factory.d.ts +84 -0
  29. package/dist/core/optimization/core/validation-engine.d.ts +107 -0
  30. package/dist/core/optimization/execution-strategy-selector.d.ts +23 -0
  31. package/dist/core/optimization/unified-validator.d.ts +45 -0
  32. package/dist/core/plugin/__tests__/test-utils.d.ts +1 -0
  33. package/dist/core/plugin/arrayContains.d.ts +37 -0
  34. package/dist/core/plugin/arrayIncludes.d.ts +42 -0
  35. package/dist/core/plugin/arrayMaxLength.d.ts +43 -0
  36. package/dist/core/plugin/arrayMinLength.d.ts +43 -0
  37. package/dist/core/plugin/arrayUnique.d.ts +41 -0
  38. package/dist/core/plugin/booleanFalsy.d.ts +41 -0
  39. package/dist/core/plugin/booleanTruthy.d.ts +38 -0
  40. package/dist/core/plugin/compareField.d.ts +58 -0
  41. package/dist/core/plugin/conditionalSchema.d.ts +24 -0
  42. package/dist/core/plugin/custom.d.ts +60 -0
  43. package/dist/core/plugin/fromContext.d.ts +150 -0
  44. package/dist/core/plugin/index.d.ts +71 -0
  45. package/dist/core/plugin/jsonSchema/dsl-converter.d.ts +22 -0
  46. package/dist/core/plugin/jsonSchema/error-generation.d.ts +14 -0
  47. package/dist/core/plugin/jsonSchema/format-validators.d.ts +20 -0
  48. package/dist/core/plugin/jsonSchema/index.d.ts +11 -0
  49. package/dist/core/plugin/jsonSchema/plugin.d.ts +35 -0
  50. package/dist/core/plugin/jsonSchema/ref-resolver.d.ts +14 -0
  51. package/dist/core/plugin/jsonSchema/types.d.ts +69 -0
  52. package/dist/core/plugin/jsonSchema/validation-core.d.ts +29 -0
  53. package/dist/core/plugin/jsonSchemaFullFeature.d.ts +31 -0
  54. package/dist/core/plugin/literal.d.ts +40 -0
  55. package/dist/core/plugin/message-factories.d.ts +9 -0
  56. package/dist/core/plugin/nullable.d.ts +34 -0
  57. package/dist/core/plugin/numberFinite.d.ts +41 -0
  58. package/dist/core/plugin/numberInteger.d.ts +41 -0
  59. package/dist/core/plugin/numberMax.d.ts +49 -0
  60. package/dist/core/plugin/numberMin.d.ts +49 -0
  61. package/dist/core/plugin/numberMultipleOf.d.ts +42 -0
  62. package/dist/core/plugin/numberNegative.d.ts +41 -0
  63. package/dist/core/plugin/numberPositive.d.ts +41 -0
  64. package/dist/core/plugin/numberRange.d.ts +48 -0
  65. package/dist/core/plugin/object.d.ts +43 -0
  66. package/dist/core/plugin/objectAdditionalProperties.d.ts +51 -0
  67. package/dist/core/plugin/objectDependentRequired.d.ts +42 -0
  68. package/dist/core/plugin/objectDependentSchemas.d.ts +40 -0
  69. package/dist/core/plugin/objectMaxProperties.d.ts +42 -0
  70. package/dist/core/plugin/objectMinProperties.d.ts +42 -0
  71. package/dist/core/plugin/objectPatternProperties.d.ts +46 -0
  72. package/dist/core/plugin/objectPropertyNames.d.ts +36 -0
  73. package/dist/core/plugin/objectRecursively.d.ts +81 -0
  74. package/dist/core/plugin/oneOf.d.ts +44 -0
  75. package/dist/core/plugin/optional.d.ts +35 -0
  76. package/dist/core/plugin/optionalIf.d.ts +42 -0
  77. package/dist/core/plugin/orFail.d.ts +132 -0
  78. package/dist/core/plugin/readOnlyWriteOnly.d.ts +48 -0
  79. package/dist/core/plugin/required.d.ts +45 -0
  80. package/dist/core/plugin/requiredIf.d.ts +66 -0
  81. package/dist/core/plugin/shared-constants.d.ts +45 -0
  82. package/dist/core/plugin/shared.d.ts +3 -0
  83. package/dist/core/plugin/skip.d.ts +57 -0
  84. package/dist/core/plugin/stitch-typed.d.ts +15 -0
  85. package/dist/core/plugin/stitch.d.ts +1 -0
  86. package/dist/core/plugin/stitchSimple.d.ts +4 -0
  87. package/dist/core/plugin/stringAlphanumeric.d.ts +42 -0
  88. package/dist/core/plugin/stringBase64.d.ts +119 -0
  89. package/dist/core/plugin/stringContentEncoding.d.ts +43 -0
  90. package/dist/core/plugin/stringContentMediaType.d.ts +47 -0
  91. package/dist/core/plugin/stringDate.d.ts +48 -0
  92. package/dist/core/plugin/stringDatetime.d.ts +108 -0
  93. package/dist/core/plugin/stringDuration.d.ts +41 -0
  94. package/dist/core/plugin/stringEmail.d.ts +81 -0
  95. package/dist/core/plugin/stringEndsWith.d.ts +42 -0
  96. package/dist/core/plugin/stringExactLength.d.ts +46 -0
  97. package/dist/core/plugin/stringHostname.d.ts +104 -0
  98. package/dist/core/plugin/stringIpv4.d.ts +85 -0
  99. package/dist/core/plugin/stringIpv6.d.ts +104 -0
  100. package/dist/core/plugin/stringIri.d.ts +117 -0
  101. package/dist/core/plugin/stringIriReference.d.ts +43 -0
  102. package/dist/core/plugin/stringJsonPointer.d.ts +107 -0
  103. package/dist/core/plugin/stringMax.d.ts +43 -0
  104. package/dist/core/plugin/stringMin.d.ts +43 -0
  105. package/dist/core/plugin/stringPattern.d.ts +40 -0
  106. package/dist/core/plugin/stringRelativeJsonPointer.d.ts +42 -0
  107. package/dist/core/plugin/stringStartsWith.d.ts +42 -0
  108. package/dist/core/plugin/stringTime.d.ts +39 -0
  109. package/dist/core/plugin/stringUriTemplate.d.ts +43 -0
  110. package/dist/core/plugin/stringUrl.d.ts +97 -0
  111. package/dist/core/plugin/testUtils.d.ts +15 -0
  112. package/dist/core/plugin/transform-type-restrictions.d.ts +61 -0
  113. package/dist/core/plugin/transform.d.ts +35 -0
  114. package/dist/core/plugin/tupleBuilder.d.ts +66 -0
  115. package/dist/core/plugin/types.d.ts +143 -0
  116. package/dist/core/plugin/unionGuard.d.ts +50 -0
  117. package/dist/core/plugin/utils/field-accessor-optimized.d.ts +50 -0
  118. package/dist/core/plugin/utils/field-accessor.d.ts +107 -0
  119. package/dist/core/plugin/uuid.d.ts +95 -0
  120. package/dist/core/plugin/validateIf.d.ts +57 -0
  121. package/dist/core/registry/plugin-registry.d.ts +116 -0
  122. package/dist/core/registry.d.ts +6 -0
  123. package/dist/core/transform/index.d.ts +1 -0
  124. package/dist/core/transform/string/defaultValue.d.ts +6 -0
  125. package/dist/core/transform/string/index.d.ts +3 -0
  126. package/dist/core/transform/string/replace.d.ts +14 -0
  127. package/dist/core/transform/string/sanitize.d.ts +6 -0
  128. package/dist/core/utils/type-guards.d.ts +68 -0
  129. package/dist/index.d.ts +72 -0
  130. package/dist/index.js +2 -0
  131. package/dist/index.js.map +7 -0
  132. package/dist/index.mjs +2 -0
  133. package/dist/index.mjs.map +7 -0
  134. package/dist/plugins/arrayContains.d.ts +37 -0
  135. package/dist/plugins/arrayContains.js +1 -0
  136. package/dist/plugins/arrayContains.mjs +1 -0
  137. package/dist/plugins/arrayIncludes.d.ts +42 -0
  138. package/dist/plugins/arrayIncludes.js +1 -0
  139. package/dist/plugins/arrayIncludes.mjs +1 -0
  140. package/dist/plugins/arrayMaxLength.d.ts +43 -0
  141. package/dist/plugins/arrayMaxLength.js +1 -0
  142. package/dist/plugins/arrayMaxLength.mjs +1 -0
  143. package/dist/plugins/arrayMinLength.d.ts +43 -0
  144. package/dist/plugins/arrayMinLength.js +1 -0
  145. package/dist/plugins/arrayMinLength.mjs +1 -0
  146. package/dist/plugins/arrayUnique.d.ts +41 -0
  147. package/dist/plugins/arrayUnique.js +1 -0
  148. package/dist/plugins/arrayUnique.mjs +1 -0
  149. package/dist/plugins/booleanFalsy.d.ts +41 -0
  150. package/dist/plugins/booleanFalsy.js +1 -0
  151. package/dist/plugins/booleanFalsy.mjs +1 -0
  152. package/dist/plugins/booleanTruthy.d.ts +38 -0
  153. package/dist/plugins/booleanTruthy.js +1 -0
  154. package/dist/plugins/booleanTruthy.mjs +1 -0
  155. package/dist/plugins/compareField.d.ts +58 -0
  156. package/dist/plugins/compareField.js +1 -0
  157. package/dist/plugins/compareField.mjs +1 -0
  158. package/dist/plugins/custom.d.ts +60 -0
  159. package/dist/plugins/custom.js +1 -0
  160. package/dist/plugins/custom.mjs +1 -0
  161. package/dist/plugins/jsonSchema.d.ts +11 -0
  162. package/dist/plugins/jsonSchema.js +1 -0
  163. package/dist/plugins/jsonSchema.mjs +1 -0
  164. package/dist/plugins/jsonSchemaFullFeature.d.ts +31 -0
  165. package/dist/plugins/jsonSchemaFullFeature.js +1 -0
  166. package/dist/plugins/jsonSchemaFullFeature.mjs +1 -0
  167. package/dist/plugins/literal.d.ts +40 -0
  168. package/dist/plugins/literal.js +1 -0
  169. package/dist/plugins/literal.mjs +1 -0
  170. package/dist/plugins/nullable.d.ts +34 -0
  171. package/dist/plugins/nullable.js +1 -0
  172. package/dist/plugins/nullable.mjs +1 -0
  173. package/dist/plugins/numberInteger.d.ts +41 -0
  174. package/dist/plugins/numberInteger.js +1 -0
  175. package/dist/plugins/numberInteger.mjs +1 -0
  176. package/dist/plugins/numberMax.d.ts +49 -0
  177. package/dist/plugins/numberMax.js +1 -0
  178. package/dist/plugins/numberMax.mjs +1 -0
  179. package/dist/plugins/numberMin.d.ts +49 -0
  180. package/dist/plugins/numberMin.js +1 -0
  181. package/dist/plugins/numberMin.mjs +1 -0
  182. package/dist/plugins/numberMultipleOf.d.ts +42 -0
  183. package/dist/plugins/numberMultipleOf.js +1 -0
  184. package/dist/plugins/numberMultipleOf.mjs +1 -0
  185. package/dist/plugins/numberNegative.d.ts +41 -0
  186. package/dist/plugins/numberNegative.js +1 -0
  187. package/dist/plugins/numberNegative.mjs +1 -0
  188. package/dist/plugins/numberPositive.d.ts +41 -0
  189. package/dist/plugins/numberPositive.js +1 -0
  190. package/dist/plugins/numberPositive.mjs +1 -0
  191. package/dist/plugins/object.d.ts +43 -0
  192. package/dist/plugins/object.js +1 -0
  193. package/dist/plugins/object.mjs +1 -0
  194. package/dist/plugins/objectAdditionalProperties.d.ts +51 -0
  195. package/dist/plugins/objectAdditionalProperties.js +1 -0
  196. package/dist/plugins/objectAdditionalProperties.mjs +1 -0
  197. package/dist/plugins/objectDependentRequired.d.ts +42 -0
  198. package/dist/plugins/objectDependentRequired.js +1 -0
  199. package/dist/plugins/objectDependentRequired.mjs +1 -0
  200. package/dist/plugins/objectDependentSchemas.d.ts +40 -0
  201. package/dist/plugins/objectDependentSchemas.js +1 -0
  202. package/dist/plugins/objectDependentSchemas.mjs +1 -0
  203. package/dist/plugins/objectMaxProperties.d.ts +42 -0
  204. package/dist/plugins/objectMaxProperties.js +1 -0
  205. package/dist/plugins/objectMaxProperties.mjs +1 -0
  206. package/dist/plugins/objectMinProperties.d.ts +42 -0
  207. package/dist/plugins/objectMinProperties.js +1 -0
  208. package/dist/plugins/objectMinProperties.mjs +1 -0
  209. package/dist/plugins/objectPatternProperties.d.ts +46 -0
  210. package/dist/plugins/objectPatternProperties.js +1 -0
  211. package/dist/plugins/objectPatternProperties.mjs +1 -0
  212. package/dist/plugins/objectPropertyNames.d.ts +36 -0
  213. package/dist/plugins/objectPropertyNames.js +1 -0
  214. package/dist/plugins/objectPropertyNames.mjs +1 -0
  215. package/dist/plugins/oneOf.d.ts +44 -0
  216. package/dist/plugins/oneOf.js +1 -0
  217. package/dist/plugins/oneOf.mjs +1 -0
  218. package/dist/plugins/optional.d.ts +35 -0
  219. package/dist/plugins/optional.js +1 -0
  220. package/dist/plugins/optional.mjs +1 -0
  221. package/dist/plugins/readOnlyWriteOnly.d.ts +48 -0
  222. package/dist/plugins/readOnlyWriteOnly.js +1 -0
  223. package/dist/plugins/readOnlyWriteOnly.mjs +1 -0
  224. package/dist/plugins/required.d.ts +45 -0
  225. package/dist/plugins/required.js +1 -0
  226. package/dist/plugins/required.mjs +1 -0
  227. package/dist/plugins/requiredIf.d.ts +66 -0
  228. package/dist/plugins/requiredIf.js +1 -0
  229. package/dist/plugins/requiredIf.mjs +1 -0
  230. package/dist/plugins/skip.d.ts +57 -0
  231. package/dist/plugins/skip.js +1 -0
  232. package/dist/plugins/skip.mjs +1 -0
  233. package/dist/plugins/stringBase64.d.ts +119 -0
  234. package/dist/plugins/stringBase64.js +1 -0
  235. package/dist/plugins/stringBase64.mjs +1 -0
  236. package/dist/plugins/stringContentEncoding.d.ts +43 -0
  237. package/dist/plugins/stringContentEncoding.js +1 -0
  238. package/dist/plugins/stringContentEncoding.mjs +1 -0
  239. package/dist/plugins/stringContentMediaType.d.ts +47 -0
  240. package/dist/plugins/stringContentMediaType.js +1 -0
  241. package/dist/plugins/stringContentMediaType.mjs +1 -0
  242. package/dist/plugins/stringDate.d.ts +48 -0
  243. package/dist/plugins/stringDate.js +1 -0
  244. package/dist/plugins/stringDate.mjs +1 -0
  245. package/dist/plugins/stringDatetime.d.ts +108 -0
  246. package/dist/plugins/stringDatetime.js +1 -0
  247. package/dist/plugins/stringDatetime.mjs +1 -0
  248. package/dist/plugins/stringDuration.d.ts +41 -0
  249. package/dist/plugins/stringDuration.js +1 -0
  250. package/dist/plugins/stringDuration.mjs +1 -0
  251. package/dist/plugins/stringEmail.d.ts +81 -0
  252. package/dist/plugins/stringEmail.js +1 -0
  253. package/dist/plugins/stringEmail.mjs +1 -0
  254. package/dist/plugins/stringHostname.d.ts +104 -0
  255. package/dist/plugins/stringHostname.js +1 -0
  256. package/dist/plugins/stringHostname.mjs +1 -0
  257. package/dist/plugins/stringIpv4.d.ts +85 -0
  258. package/dist/plugins/stringIpv4.js +1 -0
  259. package/dist/plugins/stringIpv4.mjs +1 -0
  260. package/dist/plugins/stringIpv6.d.ts +104 -0
  261. package/dist/plugins/stringIpv6.js +1 -0
  262. package/dist/plugins/stringIpv6.mjs +1 -0
  263. package/dist/plugins/stringIri.d.ts +117 -0
  264. package/dist/plugins/stringIri.js +1 -0
  265. package/dist/plugins/stringIri.mjs +1 -0
  266. package/dist/plugins/stringIriReference.d.ts +43 -0
  267. package/dist/plugins/stringIriReference.js +1 -0
  268. package/dist/plugins/stringIriReference.mjs +1 -0
  269. package/dist/plugins/stringJsonPointer.d.ts +107 -0
  270. package/dist/plugins/stringJsonPointer.js +1 -0
  271. package/dist/plugins/stringJsonPointer.mjs +1 -0
  272. package/dist/plugins/stringMax.d.ts +43 -0
  273. package/dist/plugins/stringMax.js +1 -0
  274. package/dist/plugins/stringMax.mjs +1 -0
  275. package/dist/plugins/stringMin.d.ts +43 -0
  276. package/dist/plugins/stringMin.js +1 -0
  277. package/dist/plugins/stringMin.mjs +1 -0
  278. package/dist/plugins/stringPattern.d.ts +40 -0
  279. package/dist/plugins/stringPattern.js +1 -0
  280. package/dist/plugins/stringPattern.mjs +1 -0
  281. package/dist/plugins/stringRelativeJsonPointer.d.ts +42 -0
  282. package/dist/plugins/stringRelativeJsonPointer.js +1 -0
  283. package/dist/plugins/stringRelativeJsonPointer.mjs +1 -0
  284. package/dist/plugins/stringTime.d.ts +39 -0
  285. package/dist/plugins/stringTime.js +1 -0
  286. package/dist/plugins/stringTime.mjs +1 -0
  287. package/dist/plugins/stringUriTemplate.d.ts +43 -0
  288. package/dist/plugins/stringUriTemplate.js +1 -0
  289. package/dist/plugins/stringUriTemplate.mjs +1 -0
  290. package/dist/plugins/stringUrl.d.ts +97 -0
  291. package/dist/plugins/stringUrl.js +1 -0
  292. package/dist/plugins/stringUrl.mjs +1 -0
  293. package/dist/plugins/transform.d.ts +35 -0
  294. package/dist/plugins/transform.js +1 -0
  295. package/dist/plugins/transform.mjs +1 -0
  296. package/dist/plugins/tupleBuilder.d.ts +66 -0
  297. package/dist/plugins/tupleBuilder.js +1 -0
  298. package/dist/plugins/tupleBuilder.mjs +1 -0
  299. package/dist/plugins/uuid.d.ts +95 -0
  300. package/dist/plugins/uuid.js +1 -0
  301. package/dist/plugins/uuid.mjs +1 -0
  302. package/dist/plugins/validateIf.d.ts +57 -0
  303. package/dist/plugins/validateIf.js +1 -0
  304. package/dist/plugins/validateIf.mjs +1 -0
  305. package/dist/types/array-type-analysis.d.ts +115 -0
  306. package/dist/types/index.d.ts +74 -0
  307. package/dist/types/indexed-result.d.ts +44 -0
  308. package/dist/types/result.d.ts +159 -0
  309. package/dist/types/stitch-types.d.ts +118 -0
  310. package/dist/types/util.d.ts +19 -0
  311. package/dist/types/valitator.d.ts +10 -0
  312. package/package.json +353 -0
@@ -0,0 +1,60 @@
1
+ import { ValidationOptions, MessageContext } from "./types";
2
+ /**
3
+ * @luq-plugin
4
+ * @name custom
5
+ * @category standard
6
+ * @description Allows custom validation logic
7
+ * @allowedTypes ["string", "number", "boolean", "date", "array", "object", "tuple", "union"]
8
+ * @example
9
+ * ```typescript
10
+ * // Basic custom validation
11
+ * builder.v("username", b => b.string
12
+ * .custom((value) => {
13
+ * return !reservedUsernames.includes(value);
14
+ * }, {
15
+ * code: 'RESERVED_USERNAME',
16
+ * messageFactory: ({ path }) => `${path} username is reserved`
17
+ * })
18
+ * )
19
+ *
20
+ * // With access to all values
21
+ * builder.v("confirmPassword", b => b.string
22
+ * .custom((value, rootData) => {
23
+ * return value === rootData.password;
24
+ * }, {
25
+ * code: 'PASSWORD_MISMATCH',
26
+ * messageFactory: ({ path }) => `${path} passwords do not match`
27
+ * })
28
+ * )
29
+ * ```
30
+ * @params
31
+ * - validator: (value: any, rootData?: any) => boolean - Custom validation function
32
+ * - options?: { code?: string; messageFactory?: (context: MessageContext) => string } - Error customization
33
+ * @returns Validation function with custom logic
34
+ * @customError
35
+ * ```typescript
36
+ * .custom(
37
+ * (value) => value.length > 5,
38
+ * {
39
+ * messageFactory: ({ path, value }) =>
40
+ * `${path} custom validation failed (received: ${value})`
41
+ * }
42
+ * )
43
+ * ```
44
+ */
45
+ export declare const customPlugin: import("../..").TypedPlugin<"custom", "custom", (validator: (value: any, rootData?: any) => boolean | {
46
+ valid: boolean;
47
+ message?: string;
48
+ }, options?: ValidationOptions & {
49
+ messageFactory?: (context: MessageContext) => string;
50
+ }) => {
51
+ check: (value: any, rootData?: any) => boolean;
52
+ code: string;
53
+ getErrorMessage: (value: any, path: string) => string;
54
+ params: (((value: any, rootData?: any) => boolean | {
55
+ valid: boolean;
56
+ message?: string;
57
+ }) | (ValidationOptions<{}> & {
58
+ messageFactory?: (context: MessageContext) => string;
59
+ }))[];
60
+ }, readonly ["string", "number", "boolean", "date", "array", "object", "tuple", "union"], "validator", "standard">;
@@ -0,0 +1,150 @@
1
+ /**
2
+ * fromContext Plugin - Context-based validation
3
+ *
4
+ * Generic plugin that can uniformly handle async context,
5
+ * allValues, and other context data
6
+ */
7
+ import type { ContextValidationOptions } from "../builder/plugins/plugin-interfaces";
8
+ /**
9
+ * @luq-plugin
10
+ * @name fromContext
11
+ * @category context
12
+ * @description Validation using context data (async context, allValues, etc.)
13
+ * @allowedTypes ["string", "number", "boolean", "object", "array", "date", "union", "tuple"]
14
+ * @example
15
+ * ```typescript
16
+ * // Basic usage
17
+ * const validator = Builder()
18
+ * .use(fromContextPlugin)
19
+ * .for<{ email: string }>()
20
+ * .v("email", (b) => b.string.required().fromContext({
21
+ * validate: (email, context) => ({
22
+ * valid: !context.hasEmail,
23
+ * message: "Email already exists"
24
+ * }),
25
+ * required: true
26
+ * }))
27
+ * .build();
28
+ *
29
+ * // Combination with async context
30
+ * const asyncContext = createAsyncContext<{ hasEmail: boolean }>()
31
+ * .set("hasEmail", checkEmailExists(email))
32
+ * .build();
33
+ *
34
+ * const result = await validator
35
+ * .withAsyncContext<{ hasEmail: boolean }>(asyncContext)
36
+ * .validate({ email: "test@example.com" });
37
+ *
38
+ * // Cross-field validation (using allValues)
39
+ * builder.v("confirmPassword", b => b.string.fromContext({
40
+ * validate: (confirmPassword, context, allValues) => ({
41
+ * valid: allValues.password === confirmPassword,
42
+ * message: "Password confirmation does not match"
43
+ * }),
44
+ * required: false // Async context not needed when using allValues
45
+ * }))
46
+ * ```
47
+ * @params
48
+ * - validate: (value, context, allValues) => { valid: boolean; message?: string } - Validation function
49
+ * - errorMessage?: string - Custom error message
50
+ * - required?: boolean - Whether context data is required (default: false)
51
+ * - fallbackToValid?: boolean - Whether to consider valid when no context (default: true)
52
+ * @returns Validation result using context data
53
+ * @since 0.1.0-alpha
54
+ */
55
+ export declare const fromContextPlugin: import("../..").TypedPlugin<"fromContext", "fromContext", <TContext = Record<string, any>>(options: ContextValidationOptions<TContext>) => {
56
+ check: (value: any, allValues?: any) => boolean;
57
+ code: string;
58
+ getErrorMessage: (value: any, path: string, allValues?: any) => string;
59
+ params: ContextValidationOptions<TContext>[];
60
+ __isFromContext: boolean;
61
+ __contextOptions: ContextValidationOptions<TContext>;
62
+ fromContext: {
63
+ options: ContextValidationOptions<TContext>;
64
+ required: boolean;
65
+ fallbackToValid: boolean;
66
+ errorMessage: string;
67
+ performContextValidation: (value: any, ctx: any) => {
68
+ valid: boolean;
69
+ message: string;
70
+ } | {
71
+ valid: boolean;
72
+ message?: undefined;
73
+ };
74
+ };
75
+ }, readonly ["string", "number", "boolean", "object", "array", "date", "union", "tuple"], "validator", "context">;
76
+ /**
77
+ * Convenient helper functions
78
+ */
79
+ /**
80
+ * fromContext options for email duplication check
81
+ */
82
+ export declare function emailDuplicationCheck(): ContextValidationOptions<{
83
+ hasEmail: boolean;
84
+ }>;
85
+ /**
86
+ * fromContext options for password confirmation check
87
+ */
88
+ export declare function passwordConfirmation(): ContextValidationOptions<any>;
89
+ /**
90
+ * fromContext options for inventory check
91
+ */
92
+ export declare function inventoryCheck(): ContextValidationOptions<{
93
+ inventory: Array<{
94
+ productId: string;
95
+ available: number;
96
+ }>;
97
+ }>;
98
+ /**
99
+ * fromContext options for conditional validation
100
+ */
101
+ export declare function conditionalRequired<T>(condition: (context: T, allValues: any) => boolean, message?: string): ContextValidationOptions<T>;
102
+ /**
103
+ * Type-safe fromContext helper
104
+ */
105
+ export declare function createTypedContextValidator<TValue, TContext>(options: ContextValidationOptions<TContext>): ContextValidationOptions<TContext>;
106
+ /**
107
+ * Usage example templates
108
+ */
109
+ export declare const ContextValidationTemplates: {
110
+ /**
111
+ * Email duplication check
112
+ */
113
+ emailDuplication: () => ContextValidationOptions<{
114
+ hasEmail: boolean;
115
+ }>;
116
+ /**
117
+ * Password confirmation
118
+ */
119
+ passwordConfirmation: () => ContextValidationOptions<any>;
120
+ /**
121
+ * Inventory check
122
+ */
123
+ inventoryCheck: () => ContextValidationOptions<{
124
+ inventory: Array<{
125
+ productId: string;
126
+ available: number;
127
+ }>;
128
+ }>;
129
+ /**
130
+ * User permission check
131
+ */
132
+ userPermission: <T extends {
133
+ userRole: string;
134
+ requiredRole: string;
135
+ }>() => ContextValidationOptions<T>;
136
+ /**
137
+ * Account limits check
138
+ */
139
+ accountLimits: <T extends {
140
+ currentCount: number;
141
+ maxCount: number;
142
+ }>() => ContextValidationOptions<T>;
143
+ /**
144
+ * Geo restriction check
145
+ */
146
+ geoRestriction: <T extends {
147
+ country: string;
148
+ allowedCountries: string[];
149
+ }>() => ContextValidationOptions<T>;
150
+ };
@@ -0,0 +1,71 @@
1
+ export { requiredPlugin } from "./required";
2
+ export { optionalPlugin } from "./optional";
3
+ export { nullablePlugin } from "./nullable";
4
+ export { requiredIfPlugin } from "./requiredIf";
5
+ export { optionalIfPlugin } from "./optionalIf";
6
+ export { skipPlugin } from "./skip";
7
+ export { validateIfPlugin } from "./validateIf";
8
+ export { orFailPlugin } from "./orFail";
9
+ export { oneOfPlugin } from "./oneOf";
10
+ export { literalPlugin } from "./literal";
11
+ export { compareFieldPlugin } from "./compareField";
12
+ export { customPlugin } from "./custom";
13
+ export { stitchPlugin } from "./stitch";
14
+ export { stringMinPlugin } from "./stringMin";
15
+ export { stringMaxPlugin } from "./stringMax";
16
+ export { stringExactLengthPlugin } from "./stringExactLength";
17
+ export { stringPatternPlugin } from "./stringPattern";
18
+ export { stringEmailPlugin } from "./stringEmail";
19
+ export { stringUrlPlugin } from "./stringUrl";
20
+ export { stringAlphanumericPlugin } from "./stringAlphanumeric";
21
+ export { stringStartsWithPlugin } from "./stringStartsWith";
22
+ export { stringEndsWithPlugin } from "./stringEndsWith";
23
+ export { stringDatetimePlugin } from "./stringDatetime";
24
+ export { stringDatePlugin } from "./stringDate";
25
+ export { uuidPlugin } from "./uuid";
26
+ export { stringIpv4Plugin } from "./stringIpv4";
27
+ export { stringIpv6Plugin } from "./stringIpv6";
28
+ export { stringHostnamePlugin } from "./stringHostname";
29
+ export { stringTimePlugin } from "./stringTime";
30
+ export { stringDurationPlugin } from "./stringDuration";
31
+ export { stringJsonPointerPlugin } from "./stringJsonPointer";
32
+ export { stringBase64Plugin } from "./stringBase64";
33
+ export { stringIriPlugin } from "./stringIri";
34
+ export { stringIriReferencePlugin } from "./stringIriReference";
35
+ export { stringUriTemplatePlugin } from "./stringUriTemplate";
36
+ export { stringRelativeJsonPointerPlugin } from "./stringRelativeJsonPointer";
37
+ export { stringContentEncodingPlugin } from "./stringContentEncoding";
38
+ export { stringContentMediaTypePlugin } from "./stringContentMediaType";
39
+ export { numberMinPlugin } from "./numberMin";
40
+ export { numberMaxPlugin } from "./numberMax";
41
+ export { numberPositivePlugin } from "./numberPositive";
42
+ export { numberNegativePlugin } from "./numberNegative";
43
+ export { numberIntegerPlugin } from "./numberInteger";
44
+ export { numberFinitePlugin } from "./numberFinite";
45
+ export { numberMultipleOfPlugin } from "./numberMultipleOf";
46
+ export { numberRangePlugin } from "./numberRange";
47
+ export { booleanTruthyPlugin } from "./booleanTruthy";
48
+ export { booleanFalsyPlugin } from "./booleanFalsy";
49
+ export { arrayIncludesPlugin } from "./arrayIncludes";
50
+ export { arrayUniquePlugin } from "./arrayUnique";
51
+ export { arrayMinLengthPlugin } from "./arrayMinLength";
52
+ export { arrayMaxLengthPlugin } from "./arrayMaxLength";
53
+ export { objectPlugin } from "./object";
54
+ export { objectRecursivelyPlugin as recursivelyPlugin } from "./objectRecursively";
55
+ export { objectRecursivelyPlugin } from "./objectRecursively";
56
+ export { objectMinPropertiesPlugin } from "./objectMinProperties";
57
+ export { objectMaxPropertiesPlugin } from "./objectMaxProperties";
58
+ export { objectAdditionalPropertiesPlugin } from "./objectAdditionalProperties";
59
+ export { transformPlugin } from "./transform";
60
+ export { unionGuardPlugin } from "./unionGuard";
61
+ export { tupleBuilderPlugin } from "./tupleBuilder";
62
+ export { fromContextPlugin } from "./fromContext";
63
+ export { jsonSchemaPlugin } from "./jsonSchema/index";
64
+ export { jsonSchemaFullFeaturePlugin } from "./jsonSchemaFullFeature";
65
+ export { arrayContainsPlugin } from "./arrayContains";
66
+ export { objectPropertyNamesPlugin } from "./objectPropertyNames";
67
+ export { objectPatternPropertiesPlugin } from "./objectPatternProperties";
68
+ export { objectDependentRequiredPlugin } from "./objectDependentRequired";
69
+ export { objectDependentSchemasPlugin } from "./objectDependentSchemas";
70
+ export { readOnlyWriteOnlyPlugin } from "./readOnlyWriteOnly";
71
+ export type { ValidationFunction, TransformFunction } from "./types";
@@ -0,0 +1,22 @@
1
+ import type { JSONSchema7 } from "json-schema";
2
+ import { LuqFieldDSL, LuqConstraints } from "./types";
3
+ /**
4
+ * DSL conversion utilities
5
+ * Convert JSON Schema to Luq DSL and back
6
+ */
7
+ /**
8
+ * Convert JSON Schema to Luq DSL field definitions
9
+ */
10
+ export declare const convertJsonSchemaToLuqDSL: (schema: JSONSchema7, parentPath?: string, rootSchema?: JSONSchema7) => LuqFieldDSL[];
11
+ /**
12
+ * Convert DSL field definition to builder function
13
+ */
14
+ export declare const convertDSLToFieldDefinition: (dsl: LuqFieldDSL, customFormats?: Record<string, (value: any) => boolean>) => (builder: any) => any;
15
+ /**
16
+ * Apply base type to builder chain
17
+ */
18
+ export declare const applyBaseType: (chain: any, type: LuqFieldDSL["type"]) => any;
19
+ /**
20
+ * Apply constraints to builder chain
21
+ */
22
+ export declare const applyConstraints: (chain: any, constraints: LuqConstraints, customFormats?: Record<string, (value: any) => boolean>) => any;
@@ -0,0 +1,14 @@
1
+ import type { JSONSchema7 } from "json-schema";
2
+ import { ValidationError } from "./types";
3
+ /**
4
+ * JSON Schema validation error generation
5
+ * Functions for generating detailed validation error messages
6
+ */
7
+ /**
8
+ * Generate detailed validation errors for a value against a schema
9
+ */
10
+ export declare const getDetailedValidationErrors: (value: any, schema: JSONSchema7 | boolean, customFormats?: Record<string, (value: string) => boolean>, rootSchema?: JSONSchema7, path?: string) => ValidationError[];
11
+ /**
12
+ * Get validation errors for specific path only
13
+ */
14
+ export declare const getSpecificValidationErrors: (value: any, schema: JSONSchema7 | boolean, targetPath: string, customFormats?: Record<string, (value: string) => boolean>, rootSchema?: JSONSchema7) => ValidationError[];
@@ -0,0 +1,20 @@
1
+ /**
2
+ * JSON Schema format validation utilities
3
+ * Pure functions for various string format validations
4
+ */
5
+ /**
6
+ * Format validation functions
7
+ */
8
+ export declare const formatValidators: Record<string, (value: string) => boolean>;
9
+ /**
10
+ * Validate a string value against a format
11
+ */
12
+ export declare const validateFormat: (value: string, format: string, customFormats?: Record<string, (value: string) => boolean>) => boolean;
13
+ /**
14
+ * Get all supported format names
15
+ */
16
+ export declare const getSupportedFormats: () => string[];
17
+ /**
18
+ * Check if a format is supported
19
+ */
20
+ export declare const isFormatSupported: (format: string) => boolean;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * JsonSchema Plugin - Main Entry Point
3
+ * Modular JSON Schema to Luq validator conversion
4
+ */
5
+ export { LuqFieldDSL, LuqConstraints, JsonSchemaOptions, ValidationError } from "./types";
6
+ export { resolveRef, resolveSchemaRef, resolveAllRefs } from "./ref-resolver";
7
+ export { formatValidators, validateFormat, getSupportedFormats, isFormatSupported } from "./format-validators";
8
+ export { validateValueAgainstSchema, validateType, validateMultipleTypes, validateStringConstraints, validateNumberConstraints, validateArrayConstraints, validateObjectConstraints } from "./validation-core";
9
+ export { getDetailedValidationErrors, getSpecificValidationErrors } from "./error-generation";
10
+ export { convertJsonSchemaToLuqDSL, convertDSLToFieldDefinition, applyConstraints, applyBaseType, applyBaseType as getBaseChain } from "./dsl-converter";
11
+ export { jsonSchemaPlugin } from "./plugin";
@@ -0,0 +1,35 @@
1
+ import type { JSONSchema7 } from "json-schema";
2
+ import type { BuilderExtensionPlugin, FieldBuilder } from "../../builder/plugins/plugin-types";
3
+ import { JsonSchemaOptions } from "./types";
4
+ /**
5
+ * @luq-plugin
6
+ * @name jsonSchema
7
+ * @category builder-extension
8
+ * @description Enables JSON Schema to Luq validator conversion
9
+ * @example
10
+ * ```typescript
11
+ * const validator = Builder()
12
+ * .use(jsonSchemaPlugin)
13
+ * .use(requiredPlugin)
14
+ * .use(stringMinPlugin)
15
+ * .use(stringEmailPlugin)
16
+ * .for<UserData>()
17
+ * .fromJsonSchema({
18
+ * type: 'object',
19
+ * properties: {
20
+ * email: { type: 'string', format: 'email' },
21
+ * age: { type: 'number', minimum: 18 }
22
+ * },
23
+ * required: ['email']
24
+ * })
25
+ * .build();
26
+ * ```
27
+ */
28
+ /**
29
+ * JSON Schema integration plugin for Luq
30
+ */
31
+ export declare const jsonSchemaPlugin: BuilderExtensionPlugin<"jsonSchema", "fromJsonSchema", <TBuilder extends FieldBuilder<any, any, any, any>>(schema: JSONSchema7 | unknown, options?: JsonSchemaOptions) => TBuilder>;
32
+ export { validateValueAgainstSchema } from "./validation-core";
33
+ export { getDetailedValidationErrors, getSpecificValidationErrors, } from "./error-generation";
34
+ export { convertJsonSchemaToLuqDSL, convertDSLToFieldDefinition, } from "./dsl-converter";
35
+ export { resolveRef } from "./ref-resolver";
@@ -0,0 +1,14 @@
1
+ import type { JSONSchema7 } from "json-schema";
2
+ /**
3
+ * Schema reference resolution utilities
4
+ * Pure functions for resolving JSON Schema $ref
5
+ */
6
+ export declare const resolveRef: (ref: string, rootSchema: JSONSchema7, definitions?: Record<string, JSONSchema7>) => JSONSchema7;
7
+ /**
8
+ * Check if schema has $ref and resolve it
9
+ */
10
+ export declare const resolveSchemaRef: (schema: JSONSchema7, rootSchema?: JSONSchema7, definitions?: Record<string, JSONSchema7>) => JSONSchema7;
11
+ /**
12
+ * Recursively resolve all $refs in a schema
13
+ */
14
+ export declare const resolveAllRefs: (schema: JSONSchema7, rootSchema: JSONSchema7, visited?: Set<string>) => JSONSchema7;
@@ -0,0 +1,69 @@
1
+ import type { JSONSchema7 } from "json-schema";
2
+ /**
3
+ * DSL representation for field definitions
4
+ * Extracted from main jsonSchema.ts for better testability
5
+ */
6
+ export interface LuqFieldDSL {
7
+ path: string;
8
+ type: "string" | "number" | "boolean" | "date" | "array" | "object" | "null" | "tuple";
9
+ nullable?: boolean;
10
+ multipleTypes?: string[];
11
+ allowedProperties?: string[];
12
+ constraints: LuqConstraints;
13
+ }
14
+ export interface LuqConstraints {
15
+ required?: boolean;
16
+ min?: number;
17
+ max?: number;
18
+ exclusiveMin?: number | boolean;
19
+ exclusiveMax?: number | boolean;
20
+ multipleOf?: number;
21
+ minLength?: number;
22
+ maxLength?: number;
23
+ pattern?: string;
24
+ format?: string;
25
+ contentEncoding?: string;
26
+ contentMediaType?: string;
27
+ enum?: any[];
28
+ const?: any;
29
+ integer?: boolean;
30
+ items?: JSONSchema7 | JSONSchema7[];
31
+ contains?: JSONSchema7;
32
+ minItems?: number;
33
+ maxItems?: number;
34
+ uniqueItems?: boolean;
35
+ additionalProperties?: boolean | JSONSchema7;
36
+ propertyNames?: JSONSchema7;
37
+ patternProperties?: Record<string, any>;
38
+ dependentRequired?: Record<string, string[]>;
39
+ minProperties?: number;
40
+ maxProperties?: number;
41
+ allOf?: JSONSchema7[];
42
+ anyOf?: JSONSchema7[];
43
+ oneOf?: JSONSchema7[];
44
+ not?: JSONSchema7;
45
+ if?: JSONSchema7;
46
+ then?: JSONSchema7;
47
+ else?: JSONSchema7;
48
+ conditionalValidation?: {
49
+ if: JSONSchema7;
50
+ then?: JSONSchema7;
51
+ else?: JSONSchema7;
52
+ };
53
+ requiredIf?: {
54
+ condition: JSONSchema7;
55
+ parentPath: string;
56
+ };
57
+ }
58
+ export interface JsonSchemaOptions {
59
+ strictRequired?: boolean;
60
+ allowAdditionalProperties?: boolean;
61
+ customFormats?: Record<string, (value: any) => boolean>;
62
+ }
63
+ export interface ValidationError {
64
+ path: string;
65
+ message: string;
66
+ code: string;
67
+ value?: any;
68
+ constraint?: any;
69
+ }
@@ -0,0 +1,29 @@
1
+ import type { JSONSchema7 } from "json-schema";
2
+ /**
3
+ * Type validation functions
4
+ */
5
+ export declare const validateType: (value: any, type: string) => boolean;
6
+ /**
7
+ * Validate value against multiple types (JSON Schema type array)
8
+ */
9
+ export declare const validateMultipleTypes: (value: any, types: string[]) => boolean;
10
+ /**
11
+ * Validate string constraints
12
+ */
13
+ export declare const validateStringConstraints: (value: string, schema: JSONSchema7, customFormats?: Record<string, (value: string) => boolean>) => boolean;
14
+ /**
15
+ * Validate number constraints (including integer)
16
+ */
17
+ export declare const validateNumberConstraints: (value: number, schema: JSONSchema7) => boolean;
18
+ /**
19
+ * Validate array constraints
20
+ */
21
+ export declare const validateArrayConstraints: (value: any[], schema: JSONSchema7, customFormats?: Record<string, (value: string) => boolean>, rootSchema?: JSONSchema7) => boolean;
22
+ /**
23
+ * Validate object constraints
24
+ */
25
+ export declare const validateObjectConstraints: (value: Record<string, any>, schema: JSONSchema7, customFormats?: Record<string, (value: string) => boolean>, rootSchema?: JSONSchema7) => boolean;
26
+ /**
27
+ * Main validation function
28
+ */
29
+ export declare const validateValueAgainstSchema: (value: any, schema: JSONSchema7, customFormats?: Record<string, (value: string) => boolean>, rootSchema?: JSONSchema7) => boolean;
@@ -0,0 +1,31 @@
1
+ import type { BuilderExtensionPlugin, FieldBuilder } from "../builder/plugins/plugin-types";
2
+ import type { JSONSchema7 } from "json-schema";
3
+ import type { JsonSchemaOptions } from "./jsonSchema/types";
4
+ /**
5
+ * @luq-plugin
6
+ * @name jsonSchemaFullFeature
7
+ * @category builder-extension
8
+ * @description Complete JSON Schema support with all necessary plugins pre-loaded
9
+ * @example
10
+ * ```typescript
11
+ * // Single plugin import for full JSON Schema support
12
+ * const validator = Builder()
13
+ * .use(jsonSchemaFullFeaturePlugin)
14
+ * .fromJsonSchema({
15
+ * type: 'object',
16
+ * properties: {
17
+ * email: { type: 'string', format: 'email' },
18
+ * age: { type: 'number', minimum: 18 },
19
+ * roles: {
20
+ * type: 'array',
21
+ * items: { type: 'string' },
22
+ * uniqueItems: true
23
+ * }
24
+ * },
25
+ * required: ['email'],
26
+ * additionalProperties: false
27
+ * })
28
+ * .build();
29
+ * ```
30
+ */
31
+ export declare const jsonSchemaFullFeaturePlugin: BuilderExtensionPlugin<"jsonSchemaFullFeature", "fromJsonSchema", <TBuilder extends FieldBuilder<any, any, any, any>>(schema: JSONSchema7 | unknown, options?: JsonSchemaOptions) => TBuilder>;
@@ -0,0 +1,40 @@
1
+ import { ValidationOptions } from "./types";
2
+ /**
3
+ * @luq-plugin
4
+ * @name literal
5
+ * @category standard
6
+ * @description Validates that a value exactly matches a specific literal value
7
+ * @allowedTypes ["string", "number", "boolean", "null"]
8
+ * @example
9
+ * ```typescript
10
+ * // String literal - exact value match
11
+ * const validator = Builder()
12
+ * .use(literalPlugin)
13
+ * .for<Config>()
14
+ * .v("type", (b) => b.string.literal("user"))
15
+ * .v("version", (b) => b.string.literal("v1"))
16
+ * .build();
17
+ *
18
+ * // Number and boolean literals
19
+ * builder.v("maxRetries", b => b.number.literal(3))
20
+ * builder.v("enabled", b => b.boolean.literal(true))
21
+ * ```
22
+ * @params
23
+ * - expected: string | number | boolean | null - The exact value to match
24
+ * - options?: { messageFactory?: (context: MessageContext) => string } - Optional configuration
25
+ * @returns Validation function that returns true only if value exactly matches expected
26
+ * @customError
27
+ * ```typescript
28
+ * .literal("active", {
29
+ * messageFactory: ({ path, value, params }) =>
30
+ * `${path} must be exactly "${params.expected}" (received: "${value}")`
31
+ * })
32
+ * ```
33
+ * @since 0.1.0-alpha
34
+ */
35
+ export declare const literalPlugin: import("../..").TypedPlugin<"literal", "literal", <TValue extends string | number | boolean | null>(expectedValue: TValue, options?: ValidationOptions) => {
36
+ check: (value: any) => boolean;
37
+ code: string;
38
+ getErrorMessage: (value: any, path: string) => string;
39
+ params: (ValidationOptions<{}> | TValue)[];
40
+ }, readonly ["string", "number", "boolean", "null"], "validator", "standard">;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Minimal message factory implementation
3
+ * Provides basic resolveMessage function for reporter.ts
4
+ */
5
+ import { MessageFactory, MessageContext } from "./types";
6
+ /**
7
+ * Helper to resolve error message from message factory
8
+ */
9
+ export declare function resolveMessage<TContext extends Record<string, any>>(messageFactory: MessageFactory<TContext>, context: MessageContext & TContext): string;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @luq-plugin
3
+ * @name nullable
4
+ * @category standard
5
+ * @description Allows a field to accept null as a valid value
6
+ * @allowedTypes ["string", "number", "boolean", "array", "object", "date", "union"]
7
+ * @example
8
+ * ```typescript
9
+ * // Basic usage - field can be null or valid string
10
+ * const validator = Builder()
11
+ * .use(nullablePlugin)
12
+ * .for<UserProfile>()
13
+ * .v("middleName", (b) => b.string.nullable().min(3))
14
+ * .v("avatar", (b) => b.string.nullable().url())
15
+ * .build();
16
+ *
17
+ * // With other validations - null bypasses all validators
18
+ * builder.v("score", b => b.number.nullable().min(0).max(100))
19
+ * ```
20
+ * @params
21
+ * No parameters - this is a modifier plugin
22
+ * @returns Validation function that returns true for null values and continues validation for non-null values
23
+ * @customError
24
+ * This plugin does not generate errors - it allows null values
25
+ * @since 0.1.0-alpha
26
+ */
27
+ export declare const nullablePlugin: import("../..").TypedPlugin<"nullable", "nullable", () => {
28
+ check: (value: any) => boolean;
29
+ code: string;
30
+ getErrorMessage: (value: any, path: string) => string;
31
+ params: any[];
32
+ isNullable: boolean;
33
+ skipForNull: boolean;
34
+ }, readonly ["string", "number", "boolean", "array", "object", "date", "union"], "validator", "standard">;
@@ -0,0 +1,41 @@
1
+ import { ValidationOptions } from "./types";
2
+ /**
3
+ * @luq-plugin
4
+ * @name numberFinite
5
+ * @category standard
6
+ * @description Validates that a number is finite (not Infinity, -Infinity, or NaN)
7
+ * @allowedTypes ["number"]
8
+ * @example
9
+ * ```typescript
10
+ * // Basic usage - ensures number is finite
11
+ * const validator = Builder()
12
+ * .use(numberFinitePlugin)
13
+ * .for<CalculationResult>()
14
+ * .v("score", (b) => b.number.finite())
15
+ * .v("ratio", (b) => b.number.required().finite())
16
+ * .build();
17
+ *
18
+ * // For division results that might be infinite
19
+ * builder.v("average", b => b.number.finite().min(0))
20
+ *
21
+ * // For mathematical calculations
22
+ * builder.v("result", b => b.number.required().finite().range(-1000, 1000))
23
+ * ```
24
+ * @params
25
+ * - options?: { messageFactory?: (context: MessageContext) => string } - Optional configuration
26
+ * @returns Validation function that returns true if number is finite
27
+ * @customError
28
+ * ```typescript
29
+ * .finite({
30
+ * messageFactory: ({ path, value }) =>
31
+ * `${path} must be a finite number (received: ${value})`
32
+ * })
33
+ * ```
34
+ * @since 0.1.0-alpha
35
+ */
36
+ export declare const numberFinitePlugin: import("../..").TypedPlugin<"numberFinite", "finite", (options?: ValidationOptions) => {
37
+ check: (value: any) => boolean;
38
+ code: string;
39
+ getErrorMessage: (value: any, path: string) => string;
40
+ params: ValidationOptions<{}>[];
41
+ }, readonly ["number"], "validator", "standard">;