@jarenjs/validate 0.8.4 → 0.34.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 (53) hide show
  1. package/ARCHITECTURE.md +1131 -0
  2. package/LICENSE +21 -0
  3. package/README.md +796 -2
  4. package/dist/types/array.d.ts +2 -0
  5. package/dist/types/bigint.d.ts +1 -0
  6. package/dist/types/combine.d.ts +1 -0
  7. package/dist/types/condition.d.ts +1 -0
  8. package/dist/types/content.d.ts +3 -0
  9. package/dist/types/data.d.ts +7 -0
  10. package/dist/types/dollar-data.d.ts +11 -0
  11. package/dist/types/dynamic-ref.d.ts +44 -0
  12. package/dist/types/enum.d.ts +1 -0
  13. package/dist/types/format.d.ts +21 -0
  14. package/dist/types/index.d.ts +972 -0
  15. package/dist/types/messages.d.ts +142 -0
  16. package/dist/types/normalize.d.ts +107 -0
  17. package/dist/types/number.d.ts +1 -0
  18. package/dist/types/object.d.ts +3 -0
  19. package/dist/types/query-keyword.d.ts +19 -0
  20. package/dist/types/query.d.ts +29 -0
  21. package/dist/types/schema.d.ts +1 -0
  22. package/dist/types/string.d.ts +1 -0
  23. package/dist/types/tools.d.ts +109 -0
  24. package/dist/types/traverse.d.ts +32 -0
  25. package/dist/types/unevaluated.d.ts +12 -0
  26. package/docs/ERROR-MESSAGES.md +251 -0
  27. package/package.json +37 -7
  28. package/src/array.js +610 -0
  29. package/src/bigint.js +108 -0
  30. package/src/combine.js +276 -0
  31. package/src/condition.js +129 -0
  32. package/src/content.js +83 -0
  33. package/src/data.js +101 -0
  34. package/src/dollar-data.js +212 -0
  35. package/src/dynamic-ref.js +121 -0
  36. package/src/enum.js +147 -0
  37. package/src/format.js +108 -0
  38. package/src/index.js +1896 -0
  39. package/src/messages.js +497 -0
  40. package/src/normalize.js +585 -0
  41. package/src/number.js +169 -0
  42. package/src/object.js +848 -0
  43. package/src/query-keyword.js +99 -0
  44. package/src/query.js +85 -0
  45. package/src/schema.js +690 -0
  46. package/src/string.js +164 -0
  47. package/src/tools.js +397 -0
  48. package/src/traverse.js +442 -0
  49. package/src/unevaluated.js +173 -0
  50. package/dist/index.js +0 -1998
  51. package/dist/index.js.map +0 -7
  52. package/dist/index.min.js +0 -2
  53. package/dist/index.min.js.map +0 -7
@@ -0,0 +1,2 @@
1
+ export declare function compileArrayPrimitives(schemaObj: any, jsonSchema: any): ((data: any, dataPath: any) => any) | undefined;
2
+ export declare function compileArraySchema(schemaObj: any, jsonSchema: any): ((data: any, dataPath: any, dataRoot: any) => any) | undefined;
@@ -0,0 +1 @@
1
+ export declare function compileBigIntBasic(schemaObj: any, jsonSchema: any): ((data: any, dataPath: any) => any) | undefined;
@@ -0,0 +1 @@
1
+ export declare function compileCombineSchema(schemaObj: any, jsonSchema: any): any;
@@ -0,0 +1 @@
1
+ export declare function compileConditionSchema(schemaObj: any, jsonSchema: any): ((data: any, dataPath: any, dataRoot: any, dataKey: any) => any) | undefined;
@@ -0,0 +1,3 @@
1
+ export declare function compileContentEncoding(schemaObj: any, jsonSchema: any): ((data: any, dataPath: any) => any) | undefined;
2
+ export declare function compileContentMediaType(schemaObj: any, jsonSchema: any): ((data: any, dataPath: any) => any) | undefined;
3
+ export declare function compileContentSchema(schemaObj: any, jsonSchema: any): ((data: any, dataPath: any) => any) | undefined;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Compile the data keyword schema
3
+ * @param {object} schemaObj - The validation object
4
+ * @param {object} jsonSchema - The JSON schema containing the data keyword
5
+ * @returns {function|undefined} The compiled validator function or undefined
6
+ */
7
+ export declare function compileDataSchema(schemaObj: object, jsonSchema: object): Function | undefined;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Compile $data keyword validators for a schema object
3
+ * This detects when keyword values are { $data: "..." } objects and creates
4
+ * dynamic validators that resolve the reference at validation time.
5
+ *
6
+ * @param {object} schemaObj - The validation object
7
+ * @param {object} jsonSchema - The JSON schema to compile
8
+ * @returns {function|undefined} The compiled validator function or undefined
9
+ */
10
+ export declare function compileDollarDataSchema(schemaObj: object, jsonSchema: object): Function | undefined;
11
+ export declare function isDollarDataReference(jsonSchema: any): any;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Check if a schema has $recursiveAnchor: true.
3
+ * @param {object} schema - The schema object
4
+ * @returns {boolean}
5
+ */
6
+ export declare function hasRecursiveAnchor(schema: object): boolean;
7
+ /**
8
+ * Get the $dynamicAnchor name from a schema.
9
+ * @param {object} schema - The schema object
10
+ * @returns {string|null}
11
+ */
12
+ export declare function getDynamicAnchorName(schema: object): string | null;
13
+ /**
14
+ * Collect ALL dynamic anchors of a schema RESOURCE: every $dynamicAnchor
15
+ * reachable from the given schema without crossing into an embedded
16
+ * resource (a subschema that declares its own $id).
17
+ *
18
+ * Per draft 2020-12, entering a schema resource during evaluation brings
19
+ * every $dynamicAnchor of that resource into the dynamic scope - wherever
20
+ * it sits ($defs, allOf branches, properties, ...), not just at the root.
21
+ *
22
+ * @param {object} schema - The resource root schema object
23
+ * @returns {Array<{name: string, schema: object, validator: (function|null)}>}
24
+ */
25
+ export declare function collectDynamicAnchorsDeep(schema: object): Array<{
26
+ name: string;
27
+ schema: object;
28
+ validator: (Function | null);
29
+ }>;
30
+ /**
31
+ * Collect all dynamic anchors from a schema's immediate definitions ($defs/definitions).
32
+ * This is used to find all $dynamicAnchor definitions that should be in scope
33
+ * when following a $ref from this schema.
34
+ *
35
+ * IMPORTANT: This only collects from the IMMEDIATE $defs of the given schema,
36
+ * not recursively.
37
+ *
38
+ * @param {object} schema - The schema object
39
+ * @returns {Array<{name: string, schema: object}>} Array of {name, schema} objects
40
+ */
41
+ export declare function collectDynamicAnchors(schema: object): Array<{
42
+ name: string;
43
+ schema: object;
44
+ }>;
@@ -0,0 +1 @@
1
+ export declare function compileEnumBasic(schemaObj: any, jsonSchema: any): (((data: any, dataPath: any) => any) | undefined)[];
@@ -0,0 +1,21 @@
1
+ export type FormatCompiler = import('./index.js').FormatCompiler;
2
+ /** @typedef {import('./index.js').FormatCompiler} FormatCompiler */
3
+ /**
4
+ * Registers a single format compiler under a name.
5
+ * Existing registrations are never overwritten.
6
+ * @param {Record<string, FormatCompiler>} registered - The formats registry object
7
+ * @param {string} name - The format name (e.g. 'email', 'uri', 'date-time')
8
+ * @param {FormatCompiler} formatCompiler - The compiler to register
9
+ * @returns {boolean} True when the compiler was registered
10
+ */
11
+ export declare function registerFormatCompiler(registered: Record<string, FormatCompiler>, name: string, formatCompiler: FormatCompiler): boolean;
12
+ /**
13
+ * Registers multiple format compilers at once.
14
+ * Existing registrations are never overwritten.
15
+ * @param {Record<string, FormatCompiler>} registered - The formats registry object
16
+ * @param {Record<string, FormatCompiler>} formatCompilers - Object mapping format names to compiler functions
17
+ * @returns {Record<string, FormatCompiler>} The registry object passed in
18
+ */
19
+ export declare function registerFormatCompilers(registered: Record<string, FormatCompiler>, formatCompilers: Record<string, FormatCompiler>): Record<string, FormatCompiler>;
20
+ export declare function getSchemaFormatCompiler(registered: any, name: any): any;
21
+ export declare function compileFormatBasic(schemaObj: any, jsonSchema: any): any;