typebox 1.0.42 → 1.0.44

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 (128) hide show
  1. package/build/schema/build.d.mts +6 -6
  2. package/build/schema/build.mjs +6 -4
  3. package/build/schema/check.d.mts +3 -3
  4. package/build/schema/check.mjs +4 -2
  5. package/build/schema/engine/_context.d.mts +6 -16
  6. package/build/schema/engine/_context.mjs +11 -34
  7. package/build/schema/engine/_externals.d.mts +1 -1
  8. package/build/schema/engine/_externals.mjs +2 -2
  9. package/build/schema/engine/_functions.d.mts +3 -2
  10. package/build/schema/engine/_functions.mjs +6 -5
  11. package/build/schema/engine/_guard.d.mts +5 -4
  12. package/build/schema/engine/_guard.mjs +5 -5
  13. package/build/schema/engine/_reducer.d.mts +2 -1
  14. package/build/schema/engine/_reducer.mjs +3 -3
  15. package/build/schema/engine/_refine.d.mts +4 -3
  16. package/build/schema/engine/_refine.mjs +4 -4
  17. package/build/schema/engine/_stack.d.mts +18 -0
  18. package/build/schema/engine/_stack.mjs +73 -0
  19. package/build/schema/engine/_unique.d.mts +2 -0
  20. package/build/schema/engine/_unique.mjs +5 -0
  21. package/build/schema/engine/additionalItems.d.mts +5 -4
  22. package/build/schema/engine/additionalItems.mjs +15 -13
  23. package/build/schema/engine/additionalProperties.d.mts +5 -4
  24. package/build/schema/engine/additionalProperties.mjs +19 -16
  25. package/build/schema/engine/allOf.d.mts +5 -4
  26. package/build/schema/engine/allOf.mjs +15 -15
  27. package/build/schema/engine/anyOf.d.mts +5 -4
  28. package/build/schema/engine/anyOf.mjs +15 -15
  29. package/build/schema/engine/boolean.d.mts +4 -3
  30. package/build/schema/engine/boolean.mjs +4 -4
  31. package/build/schema/engine/const.d.mts +5 -4
  32. package/build/schema/engine/const.mjs +6 -6
  33. package/build/schema/engine/contains.d.mts +5 -4
  34. package/build/schema/engine/contains.mjs +10 -8
  35. package/build/schema/engine/dependencies.d.mts +5 -4
  36. package/build/schema/engine/dependencies.mjs +6 -6
  37. package/build/schema/engine/dependentRequired.d.mts +5 -4
  38. package/build/schema/engine/dependentRequired.mjs +3 -3
  39. package/build/schema/engine/dependentSchemas.d.mts +5 -4
  40. package/build/schema/engine/dependentSchemas.mjs +6 -6
  41. package/build/schema/engine/enum.d.mts +5 -4
  42. package/build/schema/engine/enum.mjs +6 -6
  43. package/build/schema/engine/exclusiveMaximum.d.mts +5 -4
  44. package/build/schema/engine/exclusiveMaximum.mjs +4 -4
  45. package/build/schema/engine/exclusiveMinimum.d.mts +5 -4
  46. package/build/schema/engine/exclusiveMinimum.mjs +4 -4
  47. package/build/schema/engine/format.d.mts +5 -4
  48. package/build/schema/engine/format.mjs +5 -5
  49. package/build/schema/engine/if.d.mts +5 -4
  50. package/build/schema/engine/if.mjs +19 -19
  51. package/build/schema/engine/index.d.mts +12 -11
  52. package/build/schema/engine/index.mjs +13 -12
  53. package/build/schema/engine/items.d.mts +5 -4
  54. package/build/schema/engine/items.mjs +22 -22
  55. package/build/schema/engine/maxContains.d.mts +5 -4
  56. package/build/schema/engine/maxContains.mjs +11 -9
  57. package/build/schema/engine/maxItems.d.mts +5 -4
  58. package/build/schema/engine/maxItems.mjs +4 -4
  59. package/build/schema/engine/maxLength.d.mts +5 -4
  60. package/build/schema/engine/maxLength.mjs +4 -4
  61. package/build/schema/engine/maxProperties.d.mts +5 -4
  62. package/build/schema/engine/maxProperties.mjs +4 -4
  63. package/build/schema/engine/maximum.d.mts +5 -4
  64. package/build/schema/engine/maximum.mjs +4 -4
  65. package/build/schema/engine/minContains.d.mts +5 -4
  66. package/build/schema/engine/minContains.mjs +10 -8
  67. package/build/schema/engine/minItems.d.mts +5 -4
  68. package/build/schema/engine/minItems.mjs +4 -4
  69. package/build/schema/engine/minLength.d.mts +5 -4
  70. package/build/schema/engine/minLength.mjs +4 -4
  71. package/build/schema/engine/minProperties.d.mts +5 -4
  72. package/build/schema/engine/minProperties.mjs +4 -4
  73. package/build/schema/engine/minimum.d.mts +5 -4
  74. package/build/schema/engine/minimum.mjs +4 -4
  75. package/build/schema/engine/multipleOf.d.mts +5 -4
  76. package/build/schema/engine/multipleOf.mjs +4 -4
  77. package/build/schema/engine/not.d.mts +5 -4
  78. package/build/schema/engine/not.mjs +14 -13
  79. package/build/schema/engine/oneOf.d.mts +5 -4
  80. package/build/schema/engine/oneOf.mjs +14 -14
  81. package/build/schema/engine/pattern.d.mts +5 -4
  82. package/build/schema/engine/pattern.mjs +6 -6
  83. package/build/schema/engine/patternProperties.d.mts +5 -4
  84. package/build/schema/engine/patternProperties.mjs +14 -12
  85. package/build/schema/engine/prefixItems.d.mts +5 -4
  86. package/build/schema/engine/prefixItems.mjs +6 -6
  87. package/build/schema/engine/properties.d.mts +5 -4
  88. package/build/schema/engine/properties.mjs +10 -10
  89. package/build/schema/engine/propertyNames.d.mts +5 -4
  90. package/build/schema/engine/propertyNames.mjs +11 -9
  91. package/build/schema/engine/recursiveRef.d.mts +5 -4
  92. package/build/schema/engine/recursiveRef.mjs +11 -22
  93. package/build/schema/engine/ref.d.mts +5 -4
  94. package/build/schema/engine/ref.mjs +44 -29
  95. package/build/schema/engine/required.d.mts +5 -4
  96. package/build/schema/engine/required.mjs +3 -3
  97. package/build/schema/engine/schema.d.mts +5 -4
  98. package/build/schema/engine/schema.mjs +216 -207
  99. package/build/schema/engine/type.d.mts +5 -4
  100. package/build/schema/engine/type.mjs +12 -12
  101. package/build/schema/engine/unevaluatedItems.d.mts +5 -4
  102. package/build/schema/engine/unevaluatedItems.mjs +15 -13
  103. package/build/schema/engine/unevaluatedProperties.d.mts +5 -4
  104. package/build/schema/engine/unevaluatedProperties.mjs +15 -13
  105. package/build/schema/engine/uniqueItems.d.mts +5 -4
  106. package/build/schema/engine/uniqueItems.mjs +3 -3
  107. package/build/schema/errors.d.mts +3 -3
  108. package/build/schema/errors.mjs +4 -4
  109. package/build/schema/pointer/pointer.mjs +10 -2
  110. package/build/schema/resolve/index.d.mts +1 -0
  111. package/build/schema/resolve/index.mjs +1 -0
  112. package/build/schema/resolve/ref.d.mts +2 -0
  113. package/build/schema/{resolver → resolve}/ref.mjs +43 -45
  114. package/build/schema/resolve/resolve.d.mts +1 -0
  115. package/build/schema/resolve/resolve.mjs +1 -0
  116. package/build/schema/schema.d.mts +1 -1
  117. package/build/schema/schema.mjs +1 -1
  118. package/build/schema/types/recursiveAnchor.d.mts +4 -0
  119. package/build/schema/types/recursiveAnchor.mjs +7 -0
  120. package/build/type/types/static.d.mts +4 -4
  121. package/package.json +1 -1
  122. package/build/schema/resolver/index.d.mts +0 -1
  123. package/build/schema/resolver/index.mjs +0 -1
  124. package/build/schema/resolver/recursiveRef.d.mts +0 -2
  125. package/build/schema/resolver/recursiveRef.mjs +0 -47
  126. package/build/schema/resolver/ref.d.mts +0 -1
  127. package/build/schema/resolver/resolver.d.mts +0 -2
  128. package/build/schema/resolver/resolver.mjs +0 -2
@@ -3,20 +3,20 @@ import { Guard as G, EmitGuard as E } from '../../guard/index.mjs';
3
3
  // ------------------------------------------------------------------
4
4
  // Build
5
5
  // ------------------------------------------------------------------
6
- export function BuildExclusiveMinimum(context, schema, value) {
6
+ export function BuildExclusiveMinimum(stack, context, schema, value) {
7
7
  return E.IsGreaterThan(value, E.Constant(schema.exclusiveMinimum));
8
8
  }
9
9
  // ------------------------------------------------------------------
10
10
  // Check
11
11
  // ------------------------------------------------------------------
12
- export function CheckExclusiveMinimum(context, schema, value) {
12
+ export function CheckExclusiveMinimum(stack, context, schema, value) {
13
13
  return G.IsGreaterThan(value, schema.exclusiveMinimum);
14
14
  }
15
15
  // ------------------------------------------------------------------
16
16
  // Error
17
17
  // ------------------------------------------------------------------
18
- export function ErrorExclusiveMinimum(context, schemaPath, instancePath, schema, value) {
19
- return CheckExclusiveMinimum(context, schema, value) || context.AddError({
18
+ export function ErrorExclusiveMinimum(stack, context, schemaPath, instancePath, schema, value) {
19
+ return CheckExclusiveMinimum(stack, context, schema, value) || context.AddError({
20
20
  keyword: 'exclusiveMinimum',
21
21
  schemaPath,
22
22
  instancePath,
@@ -1,5 +1,6 @@
1
- import * as S from '../types/index.mjs';
1
+ import * as Schema from '../types/index.mjs';
2
+ import { Stack } from './_stack.mjs';
2
3
  import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
3
- export declare function BuildFormat(context: BuildContext, schema: S.XFormat, value: string): string;
4
- export declare function CheckFormat(context: CheckContext, schema: S.XFormat, value: string): boolean;
5
- export declare function ErrorFormat(context: ErrorContext, schemaPath: string, instancePath: string, schema: S.XFormat, value: string): boolean;
4
+ export declare function BuildFormat(stack: Stack, context: BuildContext, schema: Schema.XFormat, value: string): string;
5
+ export declare function CheckFormat(stack: Stack, context: CheckContext, schema: Schema.XFormat, value: string): boolean;
6
+ export declare function ErrorFormat(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XFormat, value: string): boolean;
@@ -1,23 +1,23 @@
1
1
  // deno-fmt-ignore-file
2
- import { EmitGuard as E } from '../../guard/index.mjs';
3
2
  import { Format } from '../../format/index.mjs';
3
+ import { EmitGuard as E } from '../../guard/index.mjs';
4
4
  // ------------------------------------------------------------------
5
5
  // Build
6
6
  // ------------------------------------------------------------------
7
- export function BuildFormat(context, schema, value) {
7
+ export function BuildFormat(stack, context, schema, value) {
8
8
  return E.Call(E.Member('Format', 'Test'), [E.Constant(schema.format), value]);
9
9
  }
10
10
  // ------------------------------------------------------------------
11
11
  // Check
12
12
  // ------------------------------------------------------------------
13
- export function CheckFormat(context, schema, value) {
13
+ export function CheckFormat(stack, context, schema, value) {
14
14
  return Format.Test(schema.format, value);
15
15
  }
16
16
  // ------------------------------------------------------------------
17
17
  // Error
18
18
  // ------------------------------------------------------------------
19
- export function ErrorFormat(context, schemaPath, instancePath, schema, value) {
20
- return CheckFormat(context, schema, value) || context.AddError({
19
+ export function ErrorFormat(stack, context, schemaPath, instancePath, schema, value) {
20
+ return CheckFormat(stack, context, schema, value) || context.AddError({
21
21
  keyword: 'format',
22
22
  schemaPath,
23
23
  instancePath,
@@ -1,5 +1,6 @@
1
- import * as S from '../types/index.mjs';
1
+ import * as Schema from '../types/index.mjs';
2
+ import { Stack } from './_stack.mjs';
2
3
  import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
3
- export declare function BuildIf(context: BuildContext, schema: S.XIf, value: string): string;
4
- export declare function CheckIf(context: CheckContext, schema: S.XIf, value: unknown): boolean;
5
- export declare function ErrorIf(context: ErrorContext, schemaPath: string, instancePath: string, schema: S.XIf, value: unknown): boolean;
4
+ export declare function BuildIf(stack: Stack, context: BuildContext, schema: Schema.XIf, value: string): string;
5
+ export declare function CheckIf(stack: Stack, context: CheckContext, schema: Schema.XIf, value: unknown): boolean;
6
+ export declare function ErrorIf(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XIf, value: unknown): boolean;
@@ -1,41 +1,41 @@
1
1
  // deno-fmt-ignore-file
2
- import * as S from '../types/index.mjs';
3
- import { EmitGuard as E } from '../../guard/index.mjs';
2
+ import * as Schema from '../types/index.mjs';
4
3
  import { AccumulatedErrorContext } from './_context.mjs';
4
+ import { EmitGuard as E } from '../../guard/index.mjs';
5
5
  import { BuildSchema, CheckSchema, ErrorSchema } from './schema.mjs';
6
6
  // ------------------------------------------------------------------
7
7
  // Build
8
8
  // ------------------------------------------------------------------
9
- export function BuildIf(context, schema, value) {
10
- const thenSchema = S.IsThen(schema) ? schema.then : true;
11
- const elseSchema = S.IsElse(schema) ? schema.else : true;
12
- return E.Ternary(BuildSchema(context, schema.if, value), BuildSchema(context, thenSchema, value), BuildSchema(context, elseSchema, value));
9
+ export function BuildIf(stack, context, schema, value) {
10
+ const thenSchema = Schema.IsThen(schema) ? schema.then : true;
11
+ const elseSchema = Schema.IsElse(schema) ? schema.else : true;
12
+ return E.Ternary(BuildSchema(stack, context, schema.if, value), BuildSchema(stack, context, thenSchema, value), BuildSchema(stack, context, elseSchema, value));
13
13
  }
14
14
  // ------------------------------------------------------------------
15
15
  // Check
16
16
  // ------------------------------------------------------------------
17
- export function CheckIf(context, schema, value) {
18
- const thenSchema = S.IsThen(schema) ? schema.then : true;
19
- const elseSchema = S.IsElse(schema) ? schema.else : true;
20
- return CheckSchema(context, schema.if, value)
21
- ? CheckSchema(context, thenSchema, value)
22
- : CheckSchema(context, elseSchema, value);
17
+ export function CheckIf(stack, context, schema, value) {
18
+ const thenSchema = Schema.IsThen(schema) ? schema.then : true;
19
+ const elseSchema = Schema.IsElse(schema) ? schema.else : true;
20
+ return CheckSchema(stack, context, schema.if, value)
21
+ ? CheckSchema(stack, context, thenSchema, value)
22
+ : CheckSchema(stack, context, elseSchema, value);
23
23
  }
24
24
  // ------------------------------------------------------------------
25
25
  // Error
26
26
  // ------------------------------------------------------------------
27
- export function ErrorIf(context, schemaPath, instancePath, schema, value) {
28
- const thenSchema = S.IsThen(schema) ? schema.then : true;
29
- const elseSchema = S.IsElse(schema) ? schema.else : true;
30
- const trueContext = new AccumulatedErrorContext(context.GetContext(), context.GetSchema());
31
- const isIf = ErrorSchema(trueContext, `${schemaPath}/if`, instancePath, schema.if, value)
32
- ? ErrorSchema(trueContext, `${schemaPath}/then`, instancePath, thenSchema, value) || context.AddError({
27
+ export function ErrorIf(stack, context, schemaPath, instancePath, schema, value) {
28
+ const thenSchema = Schema.IsThen(schema) ? schema.then : true;
29
+ const elseSchema = Schema.IsElse(schema) ? schema.else : true;
30
+ const trueContext = new AccumulatedErrorContext();
31
+ const isIf = ErrorSchema(stack, trueContext, `${schemaPath}/if`, instancePath, schema.if, value)
32
+ ? ErrorSchema(stack, trueContext, `${schemaPath}/then`, instancePath, thenSchema, value) || context.AddError({
33
33
  keyword: 'if',
34
34
  schemaPath,
35
35
  instancePath,
36
36
  params: { failingKeyword: 'then' },
37
37
  })
38
- : ErrorSchema(context, `${schemaPath}/else`, instancePath, elseSchema, value) || context.AddError({
38
+ : ErrorSchema(stack, context, `${schemaPath}/else`, instancePath, elseSchema, value) || context.AddError({
39
39
  keyword: 'if',
40
40
  schemaPath,
41
41
  instancePath,
@@ -1,31 +1,36 @@
1
1
  export * from './_context.mjs';
2
- export * from './_functions.mjs';
3
- export * from './_reducer.mjs';
4
2
  export * from './_externals.mjs';
5
3
  export * from './_guard.mjs';
4
+ export * from './_functions.mjs';
5
+ export * from './_reducer.mjs';
6
6
  export * from './_refine.mjs';
7
- export * from './additionalProperties.mjs';
7
+ export * from './_stack.mjs';
8
8
  export * from './additionalItems.mjs';
9
+ export * from './additionalProperties.mjs';
9
10
  export * from './allOf.mjs';
10
11
  export * from './anyOf.mjs';
11
12
  export * from './boolean.mjs';
12
13
  export * from './const.mjs';
13
14
  export * from './contains.mjs';
14
15
  export * from './dependencies.mjs';
16
+ export * from './dependentRequired.mjs';
17
+ export * from './dependentSchemas.mjs';
15
18
  export * from './enum.mjs';
16
19
  export * from './exclusiveMaximum.mjs';
17
20
  export * from './exclusiveMinimum.mjs';
18
21
  export * from './format.mjs';
19
22
  export * from './if.mjs';
20
23
  export * from './items.mjs';
21
- export * from './maximum.mjs';
24
+ export * from './maxContains.mjs';
22
25
  export * from './maxItems.mjs';
23
26
  export * from './maxLength.mjs';
24
27
  export * from './maxProperties.mjs';
25
- export * from './minimum.mjs';
28
+ export * from './maximum.mjs';
29
+ export * from './minContains.mjs';
26
30
  export * from './minItems.mjs';
27
31
  export * from './minLength.mjs';
28
32
  export * from './minProperties.mjs';
33
+ export * from './minimum.mjs';
29
34
  export * from './multipleOf.mjs';
30
35
  export * from './not.mjs';
31
36
  export * from './oneOf.mjs';
@@ -37,12 +42,8 @@ export * from './propertyNames.mjs';
37
42
  export * from './recursiveRef.mjs';
38
43
  export * from './ref.mjs';
39
44
  export * from './required.mjs';
45
+ export * from './schema.mjs';
40
46
  export * from './type.mjs';
41
- export * from './uniqueItems.mjs';
42
- export * from './dependentRequired.mjs';
43
- export * from './dependentSchemas.mjs';
44
- export * from './minContains.mjs';
45
- export * from './maxContains.mjs';
46
47
  export * from './unevaluatedItems.mjs';
47
48
  export * from './unevaluatedProperties.mjs';
48
- export * from './schema.mjs';
49
+ export * from './uniqueItems.mjs';
@@ -2,36 +2,41 @@
2
2
  // Infrastructure
3
3
  // ------------------------------------------------------------------
4
4
  export * from './_context.mjs';
5
+ export * from './_externals.mjs';
6
+ export * from './_guard.mjs';
5
7
  export * from './_functions.mjs';
6
8
  export * from './_reducer.mjs';
7
- export * from './_externals.mjs';
9
+ export * from './_refine.mjs';
10
+ export * from './_stack.mjs';
8
11
  // ------------------------------------------------------------------
9
12
  // Schematics
10
13
  // ------------------------------------------------------------------
11
- export * from './_guard.mjs';
12
- export * from './_refine.mjs';
13
- export * from './additionalProperties.mjs';
14
14
  export * from './additionalItems.mjs';
15
+ export * from './additionalProperties.mjs';
15
16
  export * from './allOf.mjs';
16
17
  export * from './anyOf.mjs';
17
18
  export * from './boolean.mjs';
18
19
  export * from './const.mjs';
19
20
  export * from './contains.mjs';
20
21
  export * from './dependencies.mjs';
22
+ export * from './dependentRequired.mjs';
23
+ export * from './dependentSchemas.mjs';
21
24
  export * from './enum.mjs';
22
25
  export * from './exclusiveMaximum.mjs';
23
26
  export * from './exclusiveMinimum.mjs';
24
27
  export * from './format.mjs';
25
28
  export * from './if.mjs';
26
29
  export * from './items.mjs';
27
- export * from './maximum.mjs';
30
+ export * from './maxContains.mjs';
28
31
  export * from './maxItems.mjs';
29
32
  export * from './maxLength.mjs';
30
33
  export * from './maxProperties.mjs';
31
- export * from './minimum.mjs';
34
+ export * from './maximum.mjs';
35
+ export * from './minContains.mjs';
32
36
  export * from './minItems.mjs';
33
37
  export * from './minLength.mjs';
34
38
  export * from './minProperties.mjs';
39
+ export * from './minimum.mjs';
35
40
  export * from './multipleOf.mjs';
36
41
  export * from './not.mjs';
37
42
  export * from './oneOf.mjs';
@@ -43,12 +48,8 @@ export * from './propertyNames.mjs';
43
48
  export * from './recursiveRef.mjs';
44
49
  export * from './ref.mjs';
45
50
  export * from './required.mjs';
51
+ export * from './schema.mjs';
46
52
  export * from './type.mjs';
47
- export * from './uniqueItems.mjs';
48
- export * from './dependentRequired.mjs';
49
- export * from './dependentSchemas.mjs';
50
- export * from './minContains.mjs';
51
- export * from './maxContains.mjs';
52
53
  export * from './unevaluatedItems.mjs';
53
54
  export * from './unevaluatedProperties.mjs';
54
- export * from './schema.mjs';
55
+ export * from './uniqueItems.mjs';
@@ -1,5 +1,6 @@
1
- import * as S from '../types/index.mjs';
1
+ import * as Schema from '../types/index.mjs';
2
+ import { Stack } from './_stack.mjs';
2
3
  import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
3
- export declare function BuildItems(context: BuildContext, schema: S.XItems, value: string): string;
4
- export declare function CheckItems(context: CheckContext, schema: S.XItems, value: unknown[]): boolean;
5
- export declare function ErrorItems(context: ErrorContext, schemaPath: string, instancePath: string, schema: S.XItems, value: unknown[]): boolean;
4
+ export declare function BuildItems(stack: Stack, context: BuildContext, schema: Schema.XItems, value: string): string;
5
+ export declare function CheckItems(stack: Stack, context: CheckContext, schema: Schema.XItems, value: unknown[]): boolean;
6
+ export declare function ErrorItems(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XItems, value: unknown[]): boolean;
@@ -1,68 +1,68 @@
1
1
  // deno-fmt-ignore-file
2
- import * as S from '../types/index.mjs';
2
+ import * as Schema from '../types/index.mjs';
3
3
  import { Guard as G, EmitGuard as E } from '../../guard/index.mjs';
4
4
  import { BuildSchema, CheckSchema, ErrorSchema } from './schema.mjs';
5
5
  // ------------------------------------------------------------------
6
6
  // ItemsSized
7
7
  // ------------------------------------------------------------------
8
- function BuildItemsSized(context, schema, value) {
8
+ function BuildItemsSized(stack, context, schema, value) {
9
9
  return E.ReduceAnd(schema.items.map((schema, index) => {
10
10
  const isLength = E.IsLessEqualThan(E.Member(value, 'length'), E.Constant(index));
11
- const isSchema = BuildSchema(context, schema, `${value}[${index}]`);
11
+ const isSchema = BuildSchema(stack, context, schema, `${value}[${index}]`);
12
12
  const addIndex = context.AddIndex(E.Constant(index));
13
13
  const guarded = context.UseUnevaluated() ? E.And(isSchema, addIndex) : isSchema;
14
14
  return E.Or(isLength, guarded);
15
15
  }));
16
16
  }
17
- function CheckItemsSized(context, schema, value) {
17
+ function CheckItemsSized(stack, context, schema, value) {
18
18
  return G.Every(schema.items, 0, (schema, index) => {
19
19
  return G.IsLessEqualThan(value.length, index)
20
- || (CheckSchema(context, schema, value[index]) && context.AddIndex(index));
20
+ || (CheckSchema(stack, context, schema, value[index]) && context.AddIndex(index));
21
21
  });
22
22
  }
23
- function ErrorItemsSized(context, schemaPath, instancePath, schema, value) {
23
+ function ErrorItemsSized(stack, context, schemaPath, instancePath, schema, value) {
24
24
  return G.EveryAll(schema.items, 0, (schema, index) => {
25
25
  const nextSchemaPath = `${schemaPath}/items/${index}`;
26
26
  const nextInstancePath = `${instancePath}/${index}`;
27
27
  return G.IsLessEqualThan(value.length, index)
28
- || (ErrorSchema(context, nextSchemaPath, nextInstancePath, schema, value[index]) && context.AddIndex(index));
28
+ || (ErrorSchema(stack, context, nextSchemaPath, nextInstancePath, schema, value[index]) && context.AddIndex(index));
29
29
  });
30
30
  }
31
31
  // ------------------------------------------------------------------
32
32
  // ItemsUnsized
33
33
  // ------------------------------------------------------------------
34
- function BuildItemsUnsized(context, schema, value) {
35
- const offset = S.IsPrefixItems(schema) ? schema.prefixItems.length : 0;
36
- const isSchema = BuildSchema(context, schema.items, 'element');
34
+ function BuildItemsUnsized(stack, context, schema, value) {
35
+ const offset = Schema.IsPrefixItems(schema) ? schema.prefixItems.length : 0;
36
+ const isSchema = BuildSchema(stack, context, schema.items, 'element');
37
37
  const addIndex = context.AddIndex('index');
38
38
  const guarded = context.UseUnevaluated() ? E.And(isSchema, addIndex) : isSchema;
39
39
  return E.Every(value, E.Constant(offset), ['element', 'index'], guarded);
40
40
  }
41
- function CheckItemsUnsized(context, schema, value) {
42
- const offset = S.IsPrefixItems(schema) ? schema.prefixItems.length : 0;
41
+ function CheckItemsUnsized(stack, context, schema, value) {
42
+ const offset = Schema.IsPrefixItems(schema) ? schema.prefixItems.length : 0;
43
43
  return G.Every(value, offset, (element, index) => {
44
- return CheckSchema(context, schema.items, element)
44
+ return CheckSchema(stack, context, schema.items, element)
45
45
  && context.AddIndex(index);
46
46
  });
47
47
  }
48
- function ErrorItemsUnsized(context, schemaPath, instancePath, schema, value) {
49
- const offset = S.IsPrefixItems(schema) ? schema.prefixItems.length : 0;
48
+ function ErrorItemsUnsized(stack, context, schemaPath, instancePath, schema, value) {
49
+ const offset = Schema.IsPrefixItems(schema) ? schema.prefixItems.length : 0;
50
50
  return G.EveryAll(value, offset, (element, index) => {
51
51
  const nextSchemaPath = `${schemaPath}/items`;
52
52
  const nextInstancePath = `${instancePath}/${index}`;
53
- return ErrorSchema(context, nextSchemaPath, nextInstancePath, schema.items, element)
53
+ return ErrorSchema(stack, context, nextSchemaPath, nextInstancePath, schema.items, element)
54
54
  && context.AddIndex(index);
55
55
  });
56
56
  }
57
57
  // ------------------------------------------------------------------
58
58
  // Items
59
59
  // ------------------------------------------------------------------
60
- export function BuildItems(context, schema, value) {
61
- return S.IsItemsSized(schema) ? BuildItemsSized(context, schema, value) : BuildItemsUnsized(context, schema, value);
60
+ export function BuildItems(stack, context, schema, value) {
61
+ return Schema.IsItemsSized(schema) ? BuildItemsSized(stack, context, schema, value) : BuildItemsUnsized(stack, context, schema, value);
62
62
  }
63
- export function CheckItems(context, schema, value) {
64
- return S.IsItemsSized(schema) ? CheckItemsSized(context, schema, value) : CheckItemsUnsized(context, schema, value);
63
+ export function CheckItems(stack, context, schema, value) {
64
+ return Schema.IsItemsSized(schema) ? CheckItemsSized(stack, context, schema, value) : CheckItemsUnsized(stack, context, schema, value);
65
65
  }
66
- export function ErrorItems(context, schemaPath, instancePath, schema, value) {
67
- return S.IsItemsSized(schema) ? ErrorItemsSized(context, schemaPath, instancePath, schema, value) : ErrorItemsUnsized(context, schemaPath, instancePath, schema, value);
66
+ export function ErrorItems(stack, context, schemaPath, instancePath, schema, value) {
67
+ return Schema.IsItemsSized(schema) ? ErrorItemsSized(stack, context, schemaPath, instancePath, schema, value) : ErrorItemsUnsized(stack, context, schemaPath, instancePath, schema, value);
68
68
  }
@@ -1,5 +1,6 @@
1
- import * as S from '../types/index.mjs';
1
+ import * as Schema from '../types/index.mjs';
2
+ import { Stack } from './_stack.mjs';
2
3
  import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
3
- export declare function BuildMaxContains(context: BuildContext, schema: S.XMaxContains, value: string): string;
4
- export declare function CheckMaxContains(context: CheckContext, schema: S.XMaxContains, value: unknown[]): boolean;
5
- export declare function ErrorMaxContains(context: ErrorContext, schemaPath: string, instancePath: string, schema: S.XMaxContains, value: unknown[]): boolean;
4
+ export declare function BuildMaxContains(stack: Stack, context: BuildContext, schema: Schema.XMaxContains, value: string): string;
5
+ export declare function CheckMaxContains(stack: Stack, context: CheckContext, schema: Schema.XMaxContains, value: unknown[]): boolean;
6
+ export declare function ErrorMaxContains(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XMaxContains, value: unknown[]): boolean;
@@ -1,37 +1,39 @@
1
1
  // deno-fmt-ignore-file
2
- import * as S from '../types/index.mjs';
2
+ import * as Schema from '../types/index.mjs';
3
+ import { Unique } from './_unique.mjs';
3
4
  import { Guard as G, EmitGuard as E } from '../../guard/index.mjs';
4
5
  import { BuildSchema, CheckSchema } from './schema.mjs';
5
6
  // ------------------------------------------------------------------
6
7
  // Valid
7
8
  // ------------------------------------------------------------------
8
9
  function IsValid(schema) {
9
- return S.IsContains(schema);
10
+ return Schema.IsContains(schema);
10
11
  }
11
12
  // ------------------------------------------------------------------
12
13
  // Build
13
14
  // ------------------------------------------------------------------
14
- export function BuildMaxContains(context, schema, value) {
15
+ export function BuildMaxContains(stack, context, schema, value) {
15
16
  if (!IsValid(schema))
16
17
  return E.Constant(true);
17
- const count = E.Call(E.Member(value, 'reduce'), [E.ArrowFunction(['result', 'value'], E.Ternary(BuildSchema(context, schema.contains, 'value'), E.PrefixIncrement('result'), 'result')), E.Constant(0)]);
18
+ const [result, item] = [Unique(), Unique()];
19
+ const count = E.Call(E.Member(value, 'reduce'), [E.ArrowFunction([result, item], E.Ternary(BuildSchema(stack, context, schema.contains, item), E.PrefixIncrement(result), result)), E.Constant(0)]);
18
20
  return E.IsLessEqualThan(count, E.Constant(schema.maxContains));
19
21
  }
20
22
  // ------------------------------------------------------------------
21
23
  // Check
22
24
  // ------------------------------------------------------------------
23
- export function CheckMaxContains(context, schema, value) {
25
+ export function CheckMaxContains(stack, context, schema, value) {
24
26
  if (!IsValid(schema))
25
27
  return true;
26
- const count = value.reduce((result, value) => CheckSchema(context, schema.contains, value) ? ++result : result, 0);
28
+ const count = value.reduce((result, item) => CheckSchema(stack, context, schema.contains, item) ? ++result : result, 0);
27
29
  return G.IsLessEqualThan(count, schema.maxContains);
28
30
  }
29
31
  // ------------------------------------------------------------------
30
32
  // Error
31
33
  // ------------------------------------------------------------------
32
- export function ErrorMaxContains(context, schemaPath, instancePath, schema, value) {
33
- const minContains = S.IsMinContains(schema) ? schema.minContains : 1;
34
- return CheckMaxContains(context, schema, value) || context.AddError({
34
+ export function ErrorMaxContains(stack, context, schemaPath, instancePath, schema, value) {
35
+ const minContains = Schema.IsMinContains(schema) ? schema.minContains : 1;
36
+ return CheckMaxContains(stack, context, schema, value) || context.AddError({
35
37
  keyword: 'contains',
36
38
  schemaPath,
37
39
  instancePath,
@@ -1,5 +1,6 @@
1
- import * as S from '../types/index.mjs';
1
+ import * as Schema from '../types/index.mjs';
2
+ import { Stack } from './_stack.mjs';
2
3
  import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
3
- export declare function BuildMaxItems(context: BuildContext, schema: S.XMaxItems, value: string): string;
4
- export declare function CheckMaxItems(context: CheckContext, schema: S.XMaxItems, value: unknown[]): boolean;
5
- export declare function ErrorMaxItems(context: ErrorContext, schemaPath: string, instancePath: string, schema: S.XMaxItems, value: unknown[]): boolean;
4
+ export declare function BuildMaxItems(stack: Stack, context: BuildContext, schema: Schema.XMaxItems, value: string): string;
5
+ export declare function CheckMaxItems(stack: Stack, context: CheckContext, schema: Schema.XMaxItems, value: unknown[]): boolean;
6
+ export declare function ErrorMaxItems(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XMaxItems, value: unknown[]): boolean;
@@ -3,20 +3,20 @@ import { Guard as G, EmitGuard as E } from '../../guard/index.mjs';
3
3
  // ------------------------------------------------------------------
4
4
  // Build
5
5
  // ------------------------------------------------------------------
6
- export function BuildMaxItems(context, schema, value) {
6
+ export function BuildMaxItems(stack, context, schema, value) {
7
7
  return E.IsLessEqualThan(E.Member(value, 'length'), E.Constant(schema.maxItems));
8
8
  }
9
9
  // ------------------------------------------------------------------
10
10
  // Check
11
11
  // ------------------------------------------------------------------
12
- export function CheckMaxItems(context, schema, value) {
12
+ export function CheckMaxItems(stack, context, schema, value) {
13
13
  return G.IsLessEqualThan(value.length, schema.maxItems);
14
14
  }
15
15
  // ------------------------------------------------------------------
16
16
  // Error
17
17
  // ------------------------------------------------------------------
18
- export function ErrorMaxItems(context, schemaPath, instancePath, schema, value) {
19
- return CheckMaxItems(context, schema, value) || context.AddError({
18
+ export function ErrorMaxItems(stack, context, schemaPath, instancePath, schema, value) {
19
+ return CheckMaxItems(stack, context, schema, value) || context.AddError({
20
20
  keyword: 'maxItems',
21
21
  schemaPath,
22
22
  instancePath,
@@ -1,5 +1,6 @@
1
- import * as S from '../types/index.mjs';
1
+ import * as Schema from '../types/index.mjs';
2
+ import { Stack } from './_stack.mjs';
2
3
  import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
3
- export declare function BuildMaxLength(context: BuildContext, schema: S.XMaxLength, value: string): string;
4
- export declare function CheckMaxLength(context: CheckContext, schema: S.XMaxLength, value: string): boolean;
5
- export declare function ErrorMaxLength(context: ErrorContext, schemaPath: string, instancePath: string, schema: S.XMaxLength, value: string): boolean;
4
+ export declare function BuildMaxLength(stack: Stack, context: BuildContext, schema: Schema.XMaxLength, value: string): string;
5
+ export declare function CheckMaxLength(stack: Stack, context: CheckContext, schema: Schema.XMaxLength, value: string): boolean;
6
+ export declare function ErrorMaxLength(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XMaxLength, value: string): boolean;
@@ -3,20 +3,20 @@ import { Guard as G, EmitGuard as E } from '../../guard/index.mjs';
3
3
  // ------------------------------------------------------------------
4
4
  // Build
5
5
  // ------------------------------------------------------------------
6
- export function BuildMaxLength(context, schema, value) {
6
+ export function BuildMaxLength(stack, context, schema, value) {
7
7
  return E.IsLessEqualThan(E.StringGraphemeCount(value), E.Constant(schema.maxLength));
8
8
  }
9
9
  // ------------------------------------------------------------------
10
10
  // Check
11
11
  // ------------------------------------------------------------------
12
- export function CheckMaxLength(context, schema, value) {
12
+ export function CheckMaxLength(stack, context, schema, value) {
13
13
  return G.IsLessEqualThan(G.StringGraphemeCount(value), schema.maxLength);
14
14
  }
15
15
  // ------------------------------------------------------------------
16
16
  // Error
17
17
  // ------------------------------------------------------------------
18
- export function ErrorMaxLength(context, schemaPath, instancePath, schema, value) {
19
- return CheckMaxLength(context, schema, value) || context.AddError({
18
+ export function ErrorMaxLength(stack, context, schemaPath, instancePath, schema, value) {
19
+ return CheckMaxLength(stack, context, schema, value) || context.AddError({
20
20
  keyword: 'maxLength',
21
21
  schemaPath,
22
22
  instancePath,
@@ -1,5 +1,6 @@
1
- import * as S from '../types/index.mjs';
1
+ import * as Schema from '../types/index.mjs';
2
+ import { Stack } from './_stack.mjs';
2
3
  import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
3
- export declare function BuildMaxProperties(context: BuildContext, schema: S.XMaxProperties, value: string): string;
4
- export declare function CheckMaxProperties(context: CheckContext, schema: S.XMaxProperties, value: Record<PropertyKey, unknown>): boolean;
5
- export declare function ErrorMaxProperties(context: ErrorContext, schemaPath: string, instancePath: string, schema: S.XMaxProperties, value: Record<PropertyKey, unknown>): boolean;
4
+ export declare function BuildMaxProperties(stack: Stack, context: BuildContext, schema: Schema.XMaxProperties, value: string): string;
5
+ export declare function CheckMaxProperties(stack: Stack, context: CheckContext, schema: Schema.XMaxProperties, value: Record<PropertyKey, unknown>): boolean;
6
+ export declare function ErrorMaxProperties(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XMaxProperties, value: Record<PropertyKey, unknown>): boolean;
@@ -3,20 +3,20 @@ import { EmitGuard as E, Guard as G } from '../../guard/index.mjs';
3
3
  // ------------------------------------------------------------------
4
4
  // Build
5
5
  // ------------------------------------------------------------------
6
- export function BuildMaxProperties(context, schema, value) {
6
+ export function BuildMaxProperties(stack, context, schema, value) {
7
7
  return E.IsLessEqualThan(E.Member(E.Keys(value), 'length'), E.Constant(schema.maxProperties));
8
8
  }
9
9
  // ------------------------------------------------------------------
10
10
  // Check
11
11
  // ------------------------------------------------------------------
12
- export function CheckMaxProperties(context, schema, value) {
12
+ export function CheckMaxProperties(stack, context, schema, value) {
13
13
  return G.IsLessEqualThan(G.Keys(value).length, schema.maxProperties);
14
14
  }
15
15
  // ------------------------------------------------------------------
16
16
  // Check
17
17
  // ------------------------------------------------------------------
18
- export function ErrorMaxProperties(context, schemaPath, instancePath, schema, value) {
19
- return CheckMaxProperties(context, schema, value) || context.AddError({
18
+ export function ErrorMaxProperties(stack, context, schemaPath, instancePath, schema, value) {
19
+ return CheckMaxProperties(stack, context, schema, value) || context.AddError({
20
20
  keyword: 'maxProperties',
21
21
  schemaPath,
22
22
  instancePath,
@@ -1,5 +1,6 @@
1
- import * as S from '../types/index.mjs';
1
+ import * as Schema from '../types/index.mjs';
2
+ import { Stack } from './_stack.mjs';
2
3
  import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
3
- export declare function BuildMaximum(context: BuildContext, schema: S.XMaximum, value: string): string;
4
- export declare function CheckMaximum(context: CheckContext, schema: S.XMaximum, value: number | bigint): boolean;
5
- export declare function ErrorMaximum(context: ErrorContext, schemaPath: string, instancePath: string, schema: S.XMaximum, value: number | bigint): boolean;
4
+ export declare function BuildMaximum(stack: Stack, context: BuildContext, schema: Schema.XMaximum, value: string): string;
5
+ export declare function CheckMaximum(stack: Stack, context: CheckContext, schema: Schema.XMaximum, value: number | bigint): boolean;
6
+ export declare function ErrorMaximum(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XMaximum, value: number | bigint): boolean;
@@ -3,20 +3,20 @@ import { Guard as G, EmitGuard as E } from '../../guard/index.mjs';
3
3
  // ------------------------------------------------------------------
4
4
  // Build
5
5
  // ------------------------------------------------------------------
6
- export function BuildMaximum(context, schema, value) {
6
+ export function BuildMaximum(stack, context, schema, value) {
7
7
  return E.IsLessEqualThan(value, E.Constant(schema.maximum));
8
8
  }
9
9
  // ------------------------------------------------------------------
10
10
  // Check
11
11
  // ------------------------------------------------------------------
12
- export function CheckMaximum(context, schema, value) {
12
+ export function CheckMaximum(stack, context, schema, value) {
13
13
  return G.IsLessEqualThan(value, schema.maximum);
14
14
  }
15
15
  // ------------------------------------------------------------------
16
16
  // Error
17
17
  // ------------------------------------------------------------------
18
- export function ErrorMaximum(context, schemaPath, instancePath, schema, value) {
19
- return CheckMaximum(context, schema, value) || context.AddError({
18
+ export function ErrorMaximum(stack, context, schemaPath, instancePath, schema, value) {
19
+ return CheckMaximum(stack, context, schema, value) || context.AddError({
20
20
  keyword: 'maximum',
21
21
  schemaPath,
22
22
  instancePath,
@@ -1,5 +1,6 @@
1
- import * as S from '../types/index.mjs';
1
+ import * as Schema from '../types/index.mjs';
2
+ import { Stack } from './_stack.mjs';
2
3
  import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
3
- export declare function BuildMinContains(context: BuildContext, schema: S.XMinContains, value: string): string;
4
- export declare function CheckMinContains(context: CheckContext, schema: S.XMinContains, value: unknown[]): boolean;
5
- export declare function ErrorMinContains(context: ErrorContext, schemaPath: string, instancePath: string, schema: S.XMinContains, value: unknown[]): boolean;
4
+ export declare function BuildMinContains(stack: Stack, context: BuildContext, schema: Schema.XMinContains, value: string): string;
5
+ export declare function CheckMinContains(stack: Stack, context: CheckContext, schema: Schema.XMinContains, value: unknown[]): boolean;
6
+ export declare function ErrorMinContains(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XMinContains, value: unknown[]): boolean;