@superbuilders/validate 0.1.0 → 0.1.1

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.
package/README.md CHANGED
@@ -56,7 +56,19 @@ Compiles a JSON Schema Draft 7 schema with AJV and returns a `Validator<T>`.
56
56
  const Schema = validate.compile({ type: "string" } as const)
57
57
  ```
58
58
 
59
- Do not pass explicit output generics. The output type is inferred from the schema when `json-schema-to-ts` can represent it.
59
+ Do not pass explicit output generics. The output type is inferred from the schema when `json-schema-to-ts` can represent it. String `pattern` schemas are additionally refined with `arkregex` when the pattern is a literal.
60
+
61
+ ```typescript
62
+ const SlugSchema = validate.compile({
63
+ type: "string",
64
+ pattern: "^post_[0-9]+$"
65
+ } as const)
66
+
67
+ type Slug = validate.Infer<typeof SlugSchema>
68
+ // `post_${number}`
69
+ ```
70
+
71
+ JSON Schema patterns are not implicitly anchored. Use `^` and `$` when you need full-string validation.
60
72
 
61
73
  ### `Schema.parse(value)`
62
74
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { type ErrorObject } from "ajv";
2
2
  import type { StandardJSONSchemaV1, StandardSchemaV1 } from "@standard-schema/spec";
3
+ import type * as arkregex from "arkregex";
3
4
  import type { FromSchema, JSONSchema } from "json-schema-to-ts";
4
5
  declare const ErrValidation: Error;
5
6
  declare const ErrSchemaCompilation: Error;
@@ -20,8 +21,51 @@ type Validator<T> = StandardSchemaV1<unknown, T> & StandardJSONSchemaV1<unknown,
20
21
  parse(value: unknown): ValidationResult<T>;
21
22
  };
22
23
  type Infer<TValidator> = TValidator extends Validator<infer T> ? T : never;
24
+ type RegexFlags = "u";
25
+ type JsonSchemaArray<T> = readonly T[];
26
+ type ValidateRegexPatterns<T> = T extends string | number | boolean | null | undefined ? T : T extends JsonSchemaArray<unknown> ? {
27
+ readonly [K in keyof T]: ValidateRegexPatterns<T[K]>;
28
+ } : T extends {
29
+ pattern: infer Pattern extends string;
30
+ } ? Omit<{
31
+ readonly [K in keyof T]: ValidateRegexPatterns<T[K]>;
32
+ }, "pattern"> & {
33
+ readonly pattern: arkregex.regex.validate<Pattern, RegexFlags>;
34
+ } : T extends object ? {
35
+ readonly [K in keyof T]: ValidateRegexPatterns<T[K]>;
36
+ } : T;
37
+ type RefinePattern<Base, Pattern extends string> = Base extends unknown ? Base extends string ? string extends Base ? arkregex.regex.infer<Pattern, RegexFlags> : Extract<Base, arkregex.regex.infer<Pattern, RegexFlags>> : Base : never;
38
+ type ApplyArrayPatternInference<Base, Items> = Items extends readonly unknown[] ? Base extends readonly unknown[] ? {
39
+ readonly [K in keyof Base]: K extends keyof Items ? ApplyPatternInference<Base[K], Items[K]> : Base[K];
40
+ } : Base : Items extends JSONSchema ? Base extends readonly (infer Element)[] ? ApplyPatternInference<Element, Items>[] : Base : Base;
41
+ type ApplyObjectPatternInference<Base, Props> = Base extends object ? {
42
+ [K in keyof Base]: K extends keyof Props ? ApplyPatternInference<Base[K], Props[K]> : Base[K];
43
+ } : Base;
44
+ type ApplyAllOfPatternInference<Base, Branches> = Branches extends readonly [
45
+ infer Head,
46
+ ...infer Tail
47
+ ] ? Head extends JSONSchema ? ApplyAllOfPatternInference<ApplyPatternInference<Base, Head>, Tail> : ApplyAllOfPatternInference<Base, Tail> : Base;
48
+ type InferBranchPatterns<Branches> = Branches extends readonly (infer Branch)[] ? Branch extends JSONSchema ? InferDraft07<Branch> : never : never;
49
+ type ApplyPatternInference<Base, Schema> = Schema extends {
50
+ oneOf: infer Branches;
51
+ } ? InferBranchPatterns<Branches> : Schema extends {
52
+ anyOf: infer Branches;
53
+ } ? InferBranchPatterns<Branches> : Schema extends {
54
+ allOf: infer Branches;
55
+ } ? ApplyAllOfPatternInference<Base, Branches> : Schema extends {
56
+ type: "string";
57
+ pattern: infer Pattern extends string;
58
+ } ? RefinePattern<Base, Pattern> : Schema extends {
59
+ type: readonly unknown[];
60
+ pattern: infer Pattern extends string;
61
+ } ? RefinePattern<Base, Pattern> : Schema extends {
62
+ properties: infer Props;
63
+ } ? ApplyObjectPatternInference<Base, Props> : Schema extends {
64
+ items: infer Items;
65
+ } ? ApplyArrayPatternInference<Base, Items> : Base;
66
+ type InferDraft07<TSchema extends JSONSchema> = ApplyPatternInference<FromSchema<TSchema>, TSchema>;
23
67
  declare function formatIssues(validationErrors?: readonly ErrorObject[]): string;
24
68
  declare function issues(validationErrors?: readonly ErrorObject[]): StandardSchemaV1.Issue[];
25
- declare function compile<const TSchema extends JSONSchema>(schemaSource: TSchema & Draft07JsonSchema): Validator<FromSchema<TSchema>>;
69
+ declare function compile<const TSchema extends JSONSchema>(schemaSource: TSchema & ValidateRegexPatterns<TSchema> & Draft07JsonSchema): Validator<JSONSchema extends TSchema ? unknown : InferDraft07<TSchema>>;
26
70
  export type { Draft07JsonSchema, Infer, ValidationResult, Validator };
27
71
  export { ErrSchemaCompilation, ErrUnsupportedSchemaDialect, ErrUnsupportedSchemaTarget, ErrValidation, compile, formatIssues, issues };
package/dist/index.js.map CHANGED
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
4
  "sourcesContent": [
5
- "import Ajv, { type ErrorObject } from \"ajv\"\nimport type { StandardJSONSchemaV1, StandardSchemaV1 } from \"@standard-schema/spec\"\nimport * as errors from \"@superbuilders/errors\"\nimport type { FromSchema, JSONSchema } from \"json-schema-to-ts\"\n\nconst ErrValidation = errors.new(\"json schema validation\")\nconst ErrSchemaCompilation = errors.new(\"json schema compilation\")\nconst ErrUnsupportedSchemaTarget = errors.new(\"unsupported json schema target\")\nconst ErrUnsupportedSchemaDialect = errors.new(\"unsupported json schema dialect\")\nconst DRAFT_07_SCHEMA_URL = \"http://json-schema.org/draft-07/schema#\"\n\ntype Draft07JsonSchema = JSONSchema\n\ntype ValidationSuccess<T> = {\n\tsuccess: true\n\tdata: T\n}\n\ntype ValidationFailure = {\n\tsuccess: false\n\terror: Error\n\tissues: ErrorObject[]\n}\n\ntype ValidationResult<T> = ValidationSuccess<T> | ValidationFailure\n\ntype Validator<T> = StandardSchemaV1<unknown, T> &\n\tStandardJSONSchemaV1<unknown, T> & {\n\t\tparse(value: unknown): ValidationResult<T>\n\t}\n\ntype Infer<TValidator> = TValidator extends Validator<infer T> ? T : never\n\nconst ajv = new Ajv({\n\tallErrors: true,\n\tstrict: true,\n\tstrictSchema: true,\n\tstrictNumbers: true,\n\tstrictTypes: true,\n\tstrictTuples: true,\n\tstrictRequired: true,\n\tallowUnionTypes: false,\n\tallowMatchingProperties: false,\n\tvalidateFormats: true,\n\tcoerceTypes: false,\n\tuseDefaults: false,\n\tremoveAdditional: false\n})\n\nfunction formatIssues(validationErrors?: readonly ErrorObject[]): string {\n\tif (validationErrors === undefined || validationErrors.length === 0) {\n\t\treturn \"json schema validation failed\"\n\t}\n\treturn validationErrors\n\t\t.map(function formatIssue(issue) {\n\t\t\tlet message = issue.message\n\t\t\tif (message === undefined) {\n\t\t\t\tmessage = \"json schema validation failed\"\n\t\t\t}\n\t\t\tif (issue.instancePath.length === 0) {\n\t\t\t\treturn message\n\t\t\t}\n\t\t\treturn `${issue.instancePath}: ${message}`\n\t\t})\n\t\t.join(\"; \")\n}\n\nfunction issues(validationErrors?: readonly ErrorObject[]): StandardSchemaV1.Issue[] {\n\tif (validationErrors === undefined || validationErrors.length === 0) {\n\t\treturn [{ message: \"json schema validation failed\" }]\n\t}\n\treturn validationErrors.map(function issueFromError(issue) {\n\t\tconst path = issue.instancePath\n\t\t\t.split(\"/\")\n\t\t\t.filter(function nonEmpty(part) {\n\t\t\t\treturn part.length > 0\n\t\t\t})\n\t\t\t.map(function pathSegment(part) {\n\t\t\t\treturn { key: part.replaceAll(\"~1\", \"/\").replaceAll(\"~0\", \"~\") }\n\t\t\t})\n\t\tlet message = issue.message\n\t\tif (message === undefined) {\n\t\t\tmessage = \"json schema validation failed\"\n\t\t}\n\t\treturn { message, path }\n\t})\n}\n\nfunction validationIssues(validationErrors?: ErrorObject[]): ErrorObject[] {\n\tif (validationErrors === undefined) {\n\t\treturn []\n\t}\n\treturn validationErrors\n}\n\nfunction assertDraft07SchemaDialect(schemaSource: Draft07JsonSchema): void {\n\tif (typeof schemaSource === \"boolean\") {\n\t\treturn\n\t}\n\tif (schemaSource.$schema !== undefined && schemaSource.$schema !== DRAFT_07_SCHEMA_URL) {\n\t\tthrow ErrUnsupportedSchemaDialect\n\t}\n}\n\nfunction draft07Schema(schemaSource: Draft07JsonSchema): Record<string, unknown> {\n\tif (schemaSource === true) {\n\t\treturn { $schema: DRAFT_07_SCHEMA_URL }\n\t}\n\tif (schemaSource === false) {\n\t\treturn { $schema: DRAFT_07_SCHEMA_URL, not: {} }\n\t}\n\n\treturn { $schema: DRAFT_07_SCHEMA_URL, ...structuredClone(schemaSource) }\n}\n\nfunction assertDraft07Target(options: StandardJSONSchemaV1.Options): void {\n\tif (options.target !== \"draft-07\") {\n\t\tthrow ErrUnsupportedSchemaTarget\n\t}\n}\n\nfunction buildValidator<TOutput>(schemaSource: Draft07JsonSchema): Validator<TOutput> {\n\tassertDraft07SchemaDialect(schemaSource)\n\tconst compiledResult = errors.trySync(function compileSchema() {\n\t\treturn ajv.compile<TOutput>(schemaSource)\n\t})\n\tif (compiledResult.error) {\n\t\tthrow errors.wrap(ErrSchemaCompilation, compiledResult.error.message)\n\t}\n\tconst compiled = compiledResult.data\n\n\tfunction parse(value: unknown): ValidationResult<TOutput> {\n\t\tif (compiled(value)) {\n\t\t\treturn { success: true, data: value }\n\t\t}\n\t\tconst validationErrors = validationIssues(\n\t\t\tcompiled.errors === null ? undefined : compiled.errors\n\t\t)\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: errors.wrap(ErrValidation, formatIssues(validationErrors)),\n\t\t\tissues: validationErrors\n\t\t}\n\t}\n\n\treturn {\n\t\tparse,\n\t\t\"~standard\": {\n\t\t\tversion: 1,\n\t\t\tvendor: \"@superbuilders/validate\",\n\t\t\tvalidate(value: unknown): StandardSchemaV1.Result<TOutput> {\n\t\t\t\tconst result = parse(value)\n\t\t\t\tif (result.success) {\n\t\t\t\t\treturn { value: result.data }\n\t\t\t\t}\n\t\t\t\treturn { issues: issues(result.issues) }\n\t\t\t},\n\t\t\tjsonSchema: {\n\t\t\t\tinput(options: StandardJSONSchemaV1.Options): Record<string, unknown> {\n\t\t\t\t\tassertDraft07Target(options)\n\t\t\t\t\treturn draft07Schema(schemaSource)\n\t\t\t\t},\n\t\t\t\toutput(options: StandardJSONSchemaV1.Options): Record<string, unknown> {\n\t\t\t\t\tassertDraft07Target(options)\n\t\t\t\t\treturn draft07Schema(schemaSource)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction compile<const TSchema extends JSONSchema>(\n\tschemaSource: TSchema & Draft07JsonSchema\n): Validator<FromSchema<TSchema>>\nfunction compile(schemaSource: Draft07JsonSchema): Validator<FromSchema<JSONSchema>> {\n\treturn buildValidator<FromSchema<JSONSchema>>(schemaSource)\n}\n\nexport type { Draft07JsonSchema, Infer, ValidationResult, Validator }\nexport {\n\tErrSchemaCompilation,\n\tErrUnsupportedSchemaDialect,\n\tErrUnsupportedSchemaTarget,\n\tErrValidation,\n\tcompile,\n\tformatIssues,\n\tissues\n}\n"
5
+ "import Ajv, { type ErrorObject } from \"ajv\"\nimport type { StandardJSONSchemaV1, StandardSchemaV1 } from \"@standard-schema/spec\"\nimport * as errors from \"@superbuilders/errors\"\nimport type * as arkregex from \"arkregex\"\nimport type { FromSchema, JSONSchema } from \"json-schema-to-ts\"\n\nconst ErrValidation = errors.new(\"json schema validation\")\nconst ErrSchemaCompilation = errors.new(\"json schema compilation\")\nconst ErrUnsupportedSchemaTarget = errors.new(\"unsupported json schema target\")\nconst ErrUnsupportedSchemaDialect = errors.new(\"unsupported json schema dialect\")\nconst DRAFT_07_SCHEMA_URL = \"http://json-schema.org/draft-07/schema#\"\n\ntype Draft07JsonSchema = JSONSchema\n\ntype ValidationSuccess<T> = {\n\tsuccess: true\n\tdata: T\n}\n\ntype ValidationFailure = {\n\tsuccess: false\n\terror: Error\n\tissues: ErrorObject[]\n}\n\ntype ValidationResult<T> = ValidationSuccess<T> | ValidationFailure\n\ntype Validator<T> = StandardSchemaV1<unknown, T> &\n\tStandardJSONSchemaV1<unknown, T> & {\n\t\tparse(value: unknown): ValidationResult<T>\n\t}\n\ntype Infer<TValidator> = TValidator extends Validator<infer T> ? T : never\n\ntype RegexFlags = \"u\"\n\ntype JsonSchemaArray<T> = readonly T[]\n\ntype ValidateRegexPatterns<T> = T extends string | number | boolean | null | undefined\n\t? T\n\t: T extends JsonSchemaArray<unknown>\n\t\t? { readonly [K in keyof T]: ValidateRegexPatterns<T[K]> }\n\t\t: T extends { pattern: infer Pattern extends string }\n\t\t\t? Omit<{ readonly [K in keyof T]: ValidateRegexPatterns<T[K]> }, \"pattern\"> & {\n\t\t\t\t\treadonly pattern: arkregex.regex.validate<Pattern, RegexFlags>\n\t\t\t\t}\n\t\t\t: T extends object\n\t\t\t\t? { readonly [K in keyof T]: ValidateRegexPatterns<T[K]> }\n\t\t\t\t: T\n\ntype RefinePattern<Base, Pattern extends string> = Base extends unknown\n\t? Base extends string\n\t\t? string extends Base\n\t\t\t? arkregex.regex.infer<Pattern, RegexFlags>\n\t\t\t: Extract<Base, arkregex.regex.infer<Pattern, RegexFlags>>\n\t\t: Base\n\t: never\n\ntype ApplyArrayPatternInference<Base, Items> = Items extends readonly unknown[]\n\t? Base extends readonly unknown[]\n\t\t? {\n\t\t\t\treadonly [K in keyof Base]: K extends keyof Items\n\t\t\t\t\t? ApplyPatternInference<Base[K], Items[K]>\n\t\t\t\t\t: Base[K]\n\t\t\t}\n\t\t: Base\n\t: Items extends JSONSchema\n\t\t? Base extends readonly (infer Element)[]\n\t\t\t? ApplyPatternInference<Element, Items>[]\n\t\t\t: Base\n\t\t: Base\n\ntype ApplyObjectPatternInference<Base, Props> = Base extends object\n\t? {\n\t\t\t[K in keyof Base]: K extends keyof Props ? ApplyPatternInference<Base[K], Props[K]> : Base[K]\n\t\t}\n\t: Base\n\ntype ApplyAllOfPatternInference<Base, Branches> = Branches extends readonly [\n\tinfer Head,\n\t...infer Tail\n]\n\t? Head extends JSONSchema\n\t\t? ApplyAllOfPatternInference<ApplyPatternInference<Base, Head>, Tail>\n\t\t: ApplyAllOfPatternInference<Base, Tail>\n\t: Base\n\ntype InferBranchPatterns<Branches> = Branches extends readonly (infer Branch)[]\n\t? Branch extends JSONSchema\n\t\t? InferDraft07<Branch>\n\t\t: never\n\t: never\n\ntype ApplyPatternInference<Base, Schema> = Schema extends { oneOf: infer Branches }\n\t? InferBranchPatterns<Branches>\n\t: Schema extends { anyOf: infer Branches }\n\t\t? InferBranchPatterns<Branches>\n\t\t: Schema extends { allOf: infer Branches }\n\t\t\t? ApplyAllOfPatternInference<Base, Branches>\n\t\t\t: Schema extends { type: \"string\"; pattern: infer Pattern extends string }\n\t\t\t\t? RefinePattern<Base, Pattern>\n\t\t\t\t: Schema extends { type: readonly unknown[]; pattern: infer Pattern extends string }\n\t\t\t\t\t? RefinePattern<Base, Pattern>\n\t\t\t\t\t: Schema extends { properties: infer Props }\n\t\t\t\t\t\t? ApplyObjectPatternInference<Base, Props>\n\t\t\t\t\t\t: Schema extends { items: infer Items }\n\t\t\t\t\t\t\t? ApplyArrayPatternInference<Base, Items>\n\t\t\t\t\t\t\t: Base\n\ntype InferDraft07<TSchema extends JSONSchema> = ApplyPatternInference<FromSchema<TSchema>, TSchema>\n\nconst ajv = new Ajv({\n\tallErrors: true,\n\tstrict: true,\n\tstrictSchema: true,\n\tstrictNumbers: true,\n\tstrictTypes: true,\n\tstrictTuples: true,\n\tstrictRequired: true,\n\tallowUnionTypes: false,\n\tallowMatchingProperties: false,\n\tvalidateFormats: true,\n\tcoerceTypes: false,\n\tuseDefaults: false,\n\tremoveAdditional: false\n})\n\nfunction formatIssues(validationErrors?: readonly ErrorObject[]): string {\n\tif (validationErrors === undefined || validationErrors.length === 0) {\n\t\treturn \"json schema validation failed\"\n\t}\n\treturn validationErrors\n\t\t.map(function formatIssue(issue) {\n\t\t\tlet message = issue.message\n\t\t\tif (message === undefined) {\n\t\t\t\tmessage = \"json schema validation failed\"\n\t\t\t}\n\t\t\tif (issue.instancePath.length === 0) {\n\t\t\t\treturn message\n\t\t\t}\n\t\t\treturn `${issue.instancePath}: ${message}`\n\t\t})\n\t\t.join(\"; \")\n}\n\nfunction issues(validationErrors?: readonly ErrorObject[]): StandardSchemaV1.Issue[] {\n\tif (validationErrors === undefined || validationErrors.length === 0) {\n\t\treturn [{ message: \"json schema validation failed\" }]\n\t}\n\treturn validationErrors.map(function issueFromError(issue) {\n\t\tconst path = issue.instancePath\n\t\t\t.split(\"/\")\n\t\t\t.filter(function nonEmpty(part) {\n\t\t\t\treturn part.length > 0\n\t\t\t})\n\t\t\t.map(function pathSegment(part) {\n\t\t\t\treturn { key: part.replaceAll(\"~1\", \"/\").replaceAll(\"~0\", \"~\") }\n\t\t\t})\n\t\tlet message = issue.message\n\t\tif (message === undefined) {\n\t\t\tmessage = \"json schema validation failed\"\n\t\t}\n\t\treturn { message, path }\n\t})\n}\n\nfunction validationIssues(validationErrors?: ErrorObject[]): ErrorObject[] {\n\tif (validationErrors === undefined) {\n\t\treturn []\n\t}\n\treturn validationErrors\n}\n\nfunction assertDraft07SchemaDialect(schemaSource: Draft07JsonSchema): void {\n\tif (typeof schemaSource === \"boolean\") {\n\t\treturn\n\t}\n\tif (schemaSource.$schema !== undefined && schemaSource.$schema !== DRAFT_07_SCHEMA_URL) {\n\t\tthrow ErrUnsupportedSchemaDialect\n\t}\n}\n\nfunction draft07Schema(schemaSource: Draft07JsonSchema): Record<string, unknown> {\n\tif (schemaSource === true) {\n\t\treturn { $schema: DRAFT_07_SCHEMA_URL }\n\t}\n\tif (schemaSource === false) {\n\t\treturn { $schema: DRAFT_07_SCHEMA_URL, not: {} }\n\t}\n\n\treturn { $schema: DRAFT_07_SCHEMA_URL, ...structuredClone(schemaSource) }\n}\n\nfunction assertDraft07Target(options: StandardJSONSchemaV1.Options): void {\n\tif (options.target !== \"draft-07\") {\n\t\tthrow ErrUnsupportedSchemaTarget\n\t}\n}\n\nfunction buildValidator<TOutput>(schemaSource: Draft07JsonSchema): Validator<TOutput> {\n\tassertDraft07SchemaDialect(schemaSource)\n\tconst compiledResult = errors.trySync(function compileSchema() {\n\t\treturn ajv.compile<TOutput>(schemaSource)\n\t})\n\tif (compiledResult.error) {\n\t\tthrow errors.wrap(ErrSchemaCompilation, compiledResult.error.message)\n\t}\n\tconst compiled = compiledResult.data\n\n\tfunction parse(value: unknown): ValidationResult<TOutput> {\n\t\tif (compiled(value)) {\n\t\t\treturn { success: true, data: value }\n\t\t}\n\t\tconst validationErrors = validationIssues(\n\t\t\tcompiled.errors === null ? undefined : compiled.errors\n\t\t)\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: errors.wrap(ErrValidation, formatIssues(validationErrors)),\n\t\t\tissues: validationErrors\n\t\t}\n\t}\n\n\treturn {\n\t\tparse,\n\t\t\"~standard\": {\n\t\t\tversion: 1,\n\t\t\tvendor: \"@superbuilders/validate\",\n\t\t\tvalidate(value: unknown): StandardSchemaV1.Result<TOutput> {\n\t\t\t\tconst result = parse(value)\n\t\t\t\tif (result.success) {\n\t\t\t\t\treturn { value: result.data }\n\t\t\t\t}\n\t\t\t\treturn { issues: issues(result.issues) }\n\t\t\t},\n\t\t\tjsonSchema: {\n\t\t\t\tinput(options: StandardJSONSchemaV1.Options): Record<string, unknown> {\n\t\t\t\t\tassertDraft07Target(options)\n\t\t\t\t\treturn draft07Schema(schemaSource)\n\t\t\t\t},\n\t\t\t\toutput(options: StandardJSONSchemaV1.Options): Record<string, unknown> {\n\t\t\t\t\tassertDraft07Target(options)\n\t\t\t\t\treturn draft07Schema(schemaSource)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction compile<const TSchema extends JSONSchema>(\n\tschemaSource: TSchema & ValidateRegexPatterns<TSchema> & Draft07JsonSchema\n): Validator<JSONSchema extends TSchema ? unknown : InferDraft07<TSchema>> {\n\treturn buildValidator<JSONSchema extends TSchema ? unknown : InferDraft07<TSchema>>(schemaSource)\n}\n\nexport type { Draft07JsonSchema, Infer, ValidationResult, Validator }\nexport {\n\tErrSchemaCompilation,\n\tErrUnsupportedSchemaDialect,\n\tErrUnsupportedSchemaTarget,\n\tErrValidation,\n\tcompile,\n\tformatIssues,\n\tissues\n}\n"
6
6
  ],
7
- "mappings": ";AAAA;AAEA;AAGA,IAAM,gBAAuB,WAAI,wBAAwB;AACzD,IAAM,uBAA8B,WAAI,yBAAyB;AACjE,IAAM,6BAAoC,WAAI,gCAAgC;AAC9E,IAAM,8BAAqC,WAAI,iCAAiC;AAChF,IAAM,sBAAsB;AAwB5B,IAAM,MAAM,IAAI,IAAI;AAAA,EACnB,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,eAAe;AAAA,EACf,aAAa;AAAA,EACb,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,yBAAyB;AAAA,EACzB,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,aAAa;AAAA,EACb,kBAAkB;AACnB,CAAC;AAED,SAAS,YAAY,CAAC,kBAAmD;AAAA,EACxE,IAAI,qBAAqB,aAAa,iBAAiB,WAAW,GAAG;AAAA,IACpE,OAAO;AAAA,EACR;AAAA,EACA,OAAO,iBACL,IAAI,SAAS,WAAW,CAAC,OAAO;AAAA,IAChC,IAAI,UAAU,MAAM;AAAA,IACpB,IAAI,YAAY,WAAW;AAAA,MAC1B,UAAU;AAAA,IACX;AAAA,IACA,IAAI,MAAM,aAAa,WAAW,GAAG;AAAA,MACpC,OAAO;AAAA,IACR;AAAA,IACA,OAAO,GAAG,MAAM,iBAAiB;AAAA,GACjC,EACA,KAAK,IAAI;AAAA;AAGZ,SAAS,MAAM,CAAC,kBAAqE;AAAA,EACpF,IAAI,qBAAqB,aAAa,iBAAiB,WAAW,GAAG;AAAA,IACpE,OAAO,C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IACzD,IAAI,SAAS,KAAK,GAAG;AAAA,MACpB,OAAO,EAAE,SAAS,MAAM,MAAM,MAAM;AAAA,IACrC;AAAA,IACA,MAAM,mBAAmB,iBACxB,SAAS,WAAW,OAAO,YAAY,SAAS,MACjD;AAAA,IACA,OAAO;AAAA,MACN,SAAS;AAAA,MACT,OAAc,YAAK,eAAe,aAAa,gBAAgB,CAAC;AAAA,MAChE,QAAQ;AAAA,IACT;AAAA;AAAA,EAGD,OAAO;AAAA,IACN;AAAA,IACA,aAAa;AAAA,MACZ,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,QAAQ,CAAC,OAAkD;AAAA,QAC1D,MAAM,SAAS,MAAM,KAAK;AAAA,QAC1B,IAAI,OAAO,SAAS;AAAA,UACnB,OAAO,EAAE,OAAO,OAAO,KAAK;AAAA,QAC7B;AAAA,QACA,OAAO,EAAE,QAAQ,OAAO,OAAO,MAAM,EAAE;AAAA;AAAA,MAExC,YAAY;AAAA,QACX,KAAK,CAAC,SAAgE;AAAA,UACrE,oBAAoB,OAAO;AAAA,UAC3B,OAAO,cAAc,YAAY;AAAA;AAAA,QAElC,MAAM,CAAC,SAAgE;AAAA,UACtE,oBAAoB,OAAO;AAAA,UAC3B,OAAO,cAAc,YAAY;AAAA;AAAA,MAEnC;AAAA,IACD;AAAA,EACD;AAAA;AAGD,SAAS,OAAyC,CACjD,cAC0E;AAAA,EAC1E,OAAO,eAA6E,YAAY;AAAA;",
8
8
  "debugId": "C040DE77983A6A2864756E2164756E21",
9
9
  "names": []
10
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superbuilders/validate",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "JSON Schema Draft 7 validation primitives for Superbuilders applications",
5
5
  "module": "dist/index.js",
6
6
  "main": "dist/index.js",
@@ -29,6 +29,7 @@
29
29
  "dependencies": {
30
30
  "@standard-schema/spec": "^1.1.0",
31
31
  "@superbuilders/errors": "^3.0.2",
32
+ "arkregex": "^0.0.5",
32
33
  "ajv": "^8.20.0",
33
34
  "json-schema-to-ts": "^3.1.1"
34
35
  },