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.
- package/build/schema/build.d.mts +6 -6
- package/build/schema/build.mjs +6 -4
- package/build/schema/check.d.mts +3 -3
- package/build/schema/check.mjs +4 -2
- package/build/schema/engine/_context.d.mts +6 -16
- package/build/schema/engine/_context.mjs +11 -34
- package/build/schema/engine/_externals.d.mts +1 -1
- package/build/schema/engine/_externals.mjs +2 -2
- package/build/schema/engine/_functions.d.mts +3 -2
- package/build/schema/engine/_functions.mjs +6 -5
- package/build/schema/engine/_guard.d.mts +5 -4
- package/build/schema/engine/_guard.mjs +5 -5
- package/build/schema/engine/_reducer.d.mts +2 -1
- package/build/schema/engine/_reducer.mjs +3 -3
- package/build/schema/engine/_refine.d.mts +4 -3
- package/build/schema/engine/_refine.mjs +4 -4
- package/build/schema/engine/_stack.d.mts +18 -0
- package/build/schema/engine/_stack.mjs +73 -0
- package/build/schema/engine/_unique.d.mts +2 -0
- package/build/schema/engine/_unique.mjs +5 -0
- package/build/schema/engine/additionalItems.d.mts +5 -4
- package/build/schema/engine/additionalItems.mjs +15 -13
- package/build/schema/engine/additionalProperties.d.mts +5 -4
- package/build/schema/engine/additionalProperties.mjs +19 -16
- package/build/schema/engine/allOf.d.mts +5 -4
- package/build/schema/engine/allOf.mjs +15 -15
- package/build/schema/engine/anyOf.d.mts +5 -4
- package/build/schema/engine/anyOf.mjs +15 -15
- package/build/schema/engine/boolean.d.mts +4 -3
- package/build/schema/engine/boolean.mjs +4 -4
- package/build/schema/engine/const.d.mts +5 -4
- package/build/schema/engine/const.mjs +6 -6
- package/build/schema/engine/contains.d.mts +5 -4
- package/build/schema/engine/contains.mjs +10 -8
- package/build/schema/engine/dependencies.d.mts +5 -4
- package/build/schema/engine/dependencies.mjs +6 -6
- package/build/schema/engine/dependentRequired.d.mts +5 -4
- package/build/schema/engine/dependentRequired.mjs +3 -3
- package/build/schema/engine/dependentSchemas.d.mts +5 -4
- package/build/schema/engine/dependentSchemas.mjs +6 -6
- package/build/schema/engine/enum.d.mts +5 -4
- package/build/schema/engine/enum.mjs +6 -6
- package/build/schema/engine/exclusiveMaximum.d.mts +5 -4
- package/build/schema/engine/exclusiveMaximum.mjs +4 -4
- package/build/schema/engine/exclusiveMinimum.d.mts +5 -4
- package/build/schema/engine/exclusiveMinimum.mjs +4 -4
- package/build/schema/engine/format.d.mts +5 -4
- package/build/schema/engine/format.mjs +5 -5
- package/build/schema/engine/if.d.mts +5 -4
- package/build/schema/engine/if.mjs +19 -19
- package/build/schema/engine/index.d.mts +12 -11
- package/build/schema/engine/index.mjs +13 -12
- package/build/schema/engine/items.d.mts +5 -4
- package/build/schema/engine/items.mjs +22 -22
- package/build/schema/engine/maxContains.d.mts +5 -4
- package/build/schema/engine/maxContains.mjs +11 -9
- package/build/schema/engine/maxItems.d.mts +5 -4
- package/build/schema/engine/maxItems.mjs +4 -4
- package/build/schema/engine/maxLength.d.mts +5 -4
- package/build/schema/engine/maxLength.mjs +4 -4
- package/build/schema/engine/maxProperties.d.mts +5 -4
- package/build/schema/engine/maxProperties.mjs +4 -4
- package/build/schema/engine/maximum.d.mts +5 -4
- package/build/schema/engine/maximum.mjs +4 -4
- package/build/schema/engine/minContains.d.mts +5 -4
- package/build/schema/engine/minContains.mjs +10 -8
- package/build/schema/engine/minItems.d.mts +5 -4
- package/build/schema/engine/minItems.mjs +4 -4
- package/build/schema/engine/minLength.d.mts +5 -4
- package/build/schema/engine/minLength.mjs +4 -4
- package/build/schema/engine/minProperties.d.mts +5 -4
- package/build/schema/engine/minProperties.mjs +4 -4
- package/build/schema/engine/minimum.d.mts +5 -4
- package/build/schema/engine/minimum.mjs +4 -4
- package/build/schema/engine/multipleOf.d.mts +5 -4
- package/build/schema/engine/multipleOf.mjs +4 -4
- package/build/schema/engine/not.d.mts +5 -4
- package/build/schema/engine/not.mjs +14 -13
- package/build/schema/engine/oneOf.d.mts +5 -4
- package/build/schema/engine/oneOf.mjs +14 -14
- package/build/schema/engine/pattern.d.mts +5 -4
- package/build/schema/engine/pattern.mjs +6 -6
- package/build/schema/engine/patternProperties.d.mts +5 -4
- package/build/schema/engine/patternProperties.mjs +14 -12
- package/build/schema/engine/prefixItems.d.mts +5 -4
- package/build/schema/engine/prefixItems.mjs +6 -6
- package/build/schema/engine/properties.d.mts +5 -4
- package/build/schema/engine/properties.mjs +10 -10
- package/build/schema/engine/propertyNames.d.mts +5 -4
- package/build/schema/engine/propertyNames.mjs +11 -9
- package/build/schema/engine/recursiveRef.d.mts +5 -4
- package/build/schema/engine/recursiveRef.mjs +11 -22
- package/build/schema/engine/ref.d.mts +5 -4
- package/build/schema/engine/ref.mjs +44 -29
- package/build/schema/engine/required.d.mts +5 -4
- package/build/schema/engine/required.mjs +3 -3
- package/build/schema/engine/schema.d.mts +5 -4
- package/build/schema/engine/schema.mjs +216 -207
- package/build/schema/engine/type.d.mts +5 -4
- package/build/schema/engine/type.mjs +12 -12
- package/build/schema/engine/unevaluatedItems.d.mts +5 -4
- package/build/schema/engine/unevaluatedItems.mjs +15 -13
- package/build/schema/engine/unevaluatedProperties.d.mts +5 -4
- package/build/schema/engine/unevaluatedProperties.mjs +15 -13
- package/build/schema/engine/uniqueItems.d.mts +5 -4
- package/build/schema/engine/uniqueItems.mjs +3 -3
- package/build/schema/errors.d.mts +3 -3
- package/build/schema/errors.mjs +4 -4
- package/build/schema/pointer/pointer.mjs +10 -2
- package/build/schema/resolve/index.d.mts +1 -0
- package/build/schema/resolve/index.mjs +1 -0
- package/build/schema/resolve/ref.d.mts +2 -0
- package/build/schema/{resolver → resolve}/ref.mjs +43 -45
- package/build/schema/resolve/resolve.d.mts +1 -0
- package/build/schema/resolve/resolve.mjs +1 -0
- package/build/schema/schema.d.mts +1 -1
- package/build/schema/schema.mjs +1 -1
- package/build/schema/types/recursiveAnchor.d.mts +4 -0
- package/build/schema/types/recursiveAnchor.mjs +7 -0
- package/build/type/types/static.d.mts +4 -4
- package/package.json +1 -1
- package/build/schema/resolver/index.d.mts +0 -1
- package/build/schema/resolver/index.mjs +0 -1
- package/build/schema/resolver/recursiveRef.d.mts +0 -2
- package/build/schema/resolver/recursiveRef.mjs +0 -47
- package/build/schema/resolver/ref.d.mts +0 -1
- package/build/schema/resolver/resolver.d.mts +0 -2
- package/build/schema/resolver/resolver.mjs +0 -2
|
@@ -1,36 +1,38 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
|
-
import * as
|
|
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
|
|
10
|
+
return Schema.IsContains(schema);
|
|
10
11
|
}
|
|
11
12
|
// ------------------------------------------------------------------
|
|
12
13
|
// Build
|
|
13
14
|
// ------------------------------------------------------------------
|
|
14
|
-
export function BuildMinContains(context, schema, value) {
|
|
15
|
+
export function BuildMinContains(stack, context, schema, value) {
|
|
15
16
|
if (!IsValid(schema))
|
|
16
17
|
return E.Constant(true);
|
|
17
|
-
const
|
|
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.IsGreaterEqualThan(count, E.Constant(schema.minContains));
|
|
19
21
|
}
|
|
20
22
|
// ------------------------------------------------------------------
|
|
21
23
|
// Check
|
|
22
24
|
// ------------------------------------------------------------------
|
|
23
|
-
export function CheckMinContains(context, schema, value) {
|
|
25
|
+
export function CheckMinContains(stack, context, schema, value) {
|
|
24
26
|
if (!IsValid(schema))
|
|
25
27
|
return true;
|
|
26
|
-
const count = value.reduce((result,
|
|
28
|
+
const count = value.reduce((result, item) => CheckSchema(stack, context, schema.contains, item) ? ++result : result, 0);
|
|
27
29
|
return G.IsGreaterEqualThan(count, schema.minContains);
|
|
28
30
|
}
|
|
29
31
|
// ------------------------------------------------------------------
|
|
30
32
|
// Error
|
|
31
33
|
// ------------------------------------------------------------------
|
|
32
|
-
export function ErrorMinContains(context, schemaPath, instancePath, schema, value) {
|
|
33
|
-
return CheckMinContains(context, schema, value) || context.AddError({
|
|
34
|
+
export function ErrorMinContains(stack, context, schemaPath, instancePath, schema, value) {
|
|
35
|
+
return CheckMinContains(stack, context, schema, value) || context.AddError({
|
|
34
36
|
keyword: 'contains',
|
|
35
37
|
schemaPath,
|
|
36
38
|
instancePath,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Stack } from './_stack.mjs';
|
|
2
2
|
import { BuildContext, CheckContext, ErrorContext } from './_context.mjs';
|
|
3
|
-
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
3
|
+
import * as Schema from '../types/index.mjs';
|
|
4
|
+
export declare function BuildMinItems(stack: Stack, context: BuildContext, schema: Schema.XMinItems, value: string): string;
|
|
5
|
+
export declare function CheckMinItems(stack: Stack, context: CheckContext, schema: Schema.XMinItems, value: unknown[]): boolean;
|
|
6
|
+
export declare function ErrorMinItems(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XMinItems, 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 BuildMinItems(context, schema, value) {
|
|
6
|
+
export function BuildMinItems(stack, context, schema, value) {
|
|
7
7
|
return E.IsGreaterEqualThan(E.Member(value, 'length'), E.Constant(schema.minItems));
|
|
8
8
|
}
|
|
9
9
|
// ------------------------------------------------------------------
|
|
10
10
|
// Check
|
|
11
11
|
// ------------------------------------------------------------------
|
|
12
|
-
export function CheckMinItems(context, schema, value) {
|
|
12
|
+
export function CheckMinItems(stack, context, schema, value) {
|
|
13
13
|
return G.IsGreaterEqualThan(value.length, schema.minItems);
|
|
14
14
|
}
|
|
15
15
|
// ------------------------------------------------------------------
|
|
16
16
|
// Error
|
|
17
17
|
// ------------------------------------------------------------------
|
|
18
|
-
export function ErrorMinItems(context, schemaPath, instancePath, schema, value) {
|
|
19
|
-
return CheckMinItems(context, schema, value) || context.AddError({
|
|
18
|
+
export function ErrorMinItems(stack, context, schemaPath, instancePath, schema, value) {
|
|
19
|
+
return CheckMinItems(stack, context, schema, value) || context.AddError({
|
|
20
20
|
keyword: 'minItems',
|
|
21
21
|
schemaPath,
|
|
22
22
|
instancePath,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import * as
|
|
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 BuildMinLength(context: BuildContext, schema:
|
|
4
|
-
export declare function CheckMinLength(context: CheckContext, schema:
|
|
5
|
-
export declare function ErrorMinLength(context: ErrorContext, schemaPath: string, instancePath: string, schema:
|
|
4
|
+
export declare function BuildMinLength(stack: Stack, context: BuildContext, schema: Schema.XMinLength, value: string): string;
|
|
5
|
+
export declare function CheckMinLength(stack: Stack, context: CheckContext, schema: Schema.XMinLength, value: string): boolean;
|
|
6
|
+
export declare function ErrorMinLength(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XMinLength, 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 BuildMinLength(context, schema, value) {
|
|
6
|
+
export function BuildMinLength(stack, context, schema, value) {
|
|
7
7
|
return E.IsGreaterEqualThan(E.StringGraphemeCount(value), E.Constant(schema.minLength));
|
|
8
8
|
}
|
|
9
9
|
// ------------------------------------------------------------------
|
|
10
10
|
// Check
|
|
11
11
|
// ------------------------------------------------------------------
|
|
12
|
-
export function CheckMinLength(context, schema, value) {
|
|
12
|
+
export function CheckMinLength(stack, context, schema, value) {
|
|
13
13
|
return G.IsGreaterEqualThan(G.StringGraphemeCount(value), schema.minLength);
|
|
14
14
|
}
|
|
15
15
|
// ------------------------------------------------------------------
|
|
16
16
|
// Error
|
|
17
17
|
// ------------------------------------------------------------------
|
|
18
|
-
export function ErrorMinLength(context, schemaPath, instancePath, schema, value) {
|
|
19
|
-
return CheckMinLength(context, schema, value) || context.AddError({
|
|
18
|
+
export function ErrorMinLength(stack, context, schemaPath, instancePath, schema, value) {
|
|
19
|
+
return CheckMinLength(stack, context, schema, value) || context.AddError({
|
|
20
20
|
keyword: 'minLength',
|
|
21
21
|
schemaPath,
|
|
22
22
|
instancePath,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import * as
|
|
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 BuildMinProperties(context: BuildContext, schema:
|
|
4
|
-
export declare function CheckMinProperties(context: CheckContext, schema:
|
|
5
|
-
export declare function ErrorMinProperties(context: ErrorContext, schemaPath: string, instancePath: string, schema:
|
|
4
|
+
export declare function BuildMinProperties(stack: Stack, context: BuildContext, schema: Schema.XMinProperties, value: string): string;
|
|
5
|
+
export declare function CheckMinProperties(stack: Stack, context: CheckContext, schema: Schema.XMinProperties, value: Record<PropertyKey, unknown>): boolean;
|
|
6
|
+
export declare function ErrorMinProperties(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XMinProperties, value: Record<PropertyKey, 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 BuildMinProperties(context, schema, value) {
|
|
6
|
+
export function BuildMinProperties(stack, context, schema, value) {
|
|
7
7
|
return E.IsGreaterEqualThan(E.Member(E.Keys(value), 'length'), E.Constant(schema.minProperties));
|
|
8
8
|
}
|
|
9
9
|
// ------------------------------------------------------------------
|
|
10
10
|
// Check
|
|
11
11
|
// ------------------------------------------------------------------
|
|
12
|
-
export function CheckMinProperties(context, schema, value) {
|
|
12
|
+
export function CheckMinProperties(stack, context, schema, value) {
|
|
13
13
|
return G.IsGreaterEqualThan(G.Keys(value).length, schema.minProperties);
|
|
14
14
|
}
|
|
15
15
|
// ------------------------------------------------------------------
|
|
16
16
|
// Error
|
|
17
17
|
// ------------------------------------------------------------------
|
|
18
|
-
export function ErrorMinProperties(context, schemaPath, instancePath, schema, value) {
|
|
19
|
-
return CheckMinProperties(context, schema, value) || context.AddError({
|
|
18
|
+
export function ErrorMinProperties(stack, context, schemaPath, instancePath, schema, value) {
|
|
19
|
+
return CheckMinProperties(stack, context, schema, value) || context.AddError({
|
|
20
20
|
keyword: 'minProperties',
|
|
21
21
|
schemaPath,
|
|
22
22
|
instancePath,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import * as
|
|
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 BuildMinimum(context: BuildContext, schema:
|
|
4
|
-
export declare function CheckMinimum(context: CheckContext, schema:
|
|
5
|
-
export declare function ErrorMinimum(context: ErrorContext, schemaPath: string, instancePath: string, schema:
|
|
4
|
+
export declare function BuildMinimum(stack: Stack, context: BuildContext, schema: Schema.XMinimum, value: string): string;
|
|
5
|
+
export declare function CheckMinimum(stack: Stack, context: CheckContext, schema: Schema.XMinimum, value: number | bigint): boolean;
|
|
6
|
+
export declare function ErrorMinimum(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XMinimum, 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 BuildMinimum(context, schema, value) {
|
|
6
|
+
export function BuildMinimum(stack, context, schema, value) {
|
|
7
7
|
return E.IsGreaterEqualThan(value, E.Constant(schema.minimum));
|
|
8
8
|
}
|
|
9
9
|
// ------------------------------------------------------------------
|
|
10
10
|
// Check
|
|
11
11
|
// ------------------------------------------------------------------
|
|
12
|
-
export function CheckMinimum(context, schema, value) {
|
|
12
|
+
export function CheckMinimum(stack, context, schema, value) {
|
|
13
13
|
return G.IsGreaterEqualThan(value, schema.minimum);
|
|
14
14
|
}
|
|
15
15
|
// ------------------------------------------------------------------
|
|
16
16
|
// Error
|
|
17
17
|
// ------------------------------------------------------------------
|
|
18
|
-
export function ErrorMinimum(context, schemaPath, instancePath, schema, value) {
|
|
19
|
-
return CheckMinimum(context, schema, value) || context.AddError({
|
|
18
|
+
export function ErrorMinimum(stack, context, schemaPath, instancePath, schema, value) {
|
|
19
|
+
return CheckMinimum(stack, context, schema, value) || context.AddError({
|
|
20
20
|
keyword: 'minimum',
|
|
21
21
|
schemaPath,
|
|
22
22
|
instancePath,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import * as
|
|
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 BuildMultipleOf(context: BuildContext, schema:
|
|
4
|
-
export declare function CheckMultipleOf(context: CheckContext, schema:
|
|
5
|
-
export declare function ErrorMultipleOf(context: ErrorContext, schemaPath: string, instancePath: string, schema:
|
|
4
|
+
export declare function BuildMultipleOf(stack: Stack, context: BuildContext, schema: Schema.XMultipleOf, value: string): string;
|
|
5
|
+
export declare function CheckMultipleOf(stack: Stack, context: CheckContext, schema: Schema.XMultipleOf, value: number | bigint): boolean;
|
|
6
|
+
export declare function ErrorMultipleOf(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XMultipleOf, 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 BuildMultipleOf(context, schema, value) {
|
|
6
|
+
export function BuildMultipleOf(stack, context, schema, value) {
|
|
7
7
|
return E.MultipleOf(value, E.Constant(schema.multipleOf));
|
|
8
8
|
}
|
|
9
9
|
// ------------------------------------------------------------------
|
|
10
10
|
// Check
|
|
11
11
|
// ------------------------------------------------------------------
|
|
12
|
-
export function CheckMultipleOf(context, schema, value) {
|
|
12
|
+
export function CheckMultipleOf(stack, context, schema, value) {
|
|
13
13
|
return G.IsMultipleOf(value, schema.multipleOf);
|
|
14
14
|
}
|
|
15
15
|
// ------------------------------------------------------------------
|
|
16
16
|
// Error
|
|
17
17
|
// ------------------------------------------------------------------
|
|
18
|
-
export function ErrorMultipleOf(context, schemaPath, instancePath, schema, value) {
|
|
19
|
-
return CheckMultipleOf(context, schema, value) || context.AddError({
|
|
18
|
+
export function ErrorMultipleOf(stack, context, schemaPath, instancePath, schema, value) {
|
|
19
|
+
return CheckMultipleOf(stack, context, schema, value) || context.AddError({
|
|
20
20
|
keyword: 'multipleOf',
|
|
21
21
|
schemaPath,
|
|
22
22
|
instancePath,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import * as
|
|
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 BuildNot(context: BuildContext, schema:
|
|
4
|
-
export declare function CheckNot(context: CheckContext, schema:
|
|
5
|
-
export declare function ErrorNot(context: ErrorContext, schemaPath: string, instancePath: string, schema:
|
|
4
|
+
export declare function BuildNot(stack: Stack, context: BuildContext, schema: Schema.XNot, value: string): string;
|
|
5
|
+
export declare function CheckNot(stack: Stack, context: CheckContext, schema: Schema.XNot, value: unknown): boolean;
|
|
6
|
+
export declare function ErrorNot(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XNot, value: unknown): boolean;
|
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
|
+
import { CheckContext } from './_context.mjs';
|
|
3
|
+
import { Reducer } from './_reducer.mjs';
|
|
2
4
|
import { EmitGuard as E } from '../../guard/index.mjs';
|
|
3
5
|
import { BuildSchema, CheckSchema } from './schema.mjs';
|
|
4
|
-
import { Reducer } from './_reducer.mjs';
|
|
5
6
|
// ------------------------------------------------------------------
|
|
6
7
|
// Build
|
|
7
8
|
// ------------------------------------------------------------------
|
|
8
|
-
function BuildNotUnevaluated(context, schema, value) {
|
|
9
|
-
return Reducer(context, [schema.not], value, E.Not(E.IsEqual(E.Member('results', 'length'), E.Constant(1))));
|
|
9
|
+
function BuildNotUnevaluated(stack, context, schema, value) {
|
|
10
|
+
return Reducer(stack, context, [schema.not], value, E.Not(E.IsEqual(E.Member('results', 'length'), E.Constant(1))));
|
|
10
11
|
}
|
|
11
|
-
function BuildNotFast(context, schema, value) {
|
|
12
|
-
return E.Not(BuildSchema(context, schema.not, value));
|
|
12
|
+
function BuildNotFast(stack, context, schema, value) {
|
|
13
|
+
return E.Not(BuildSchema(stack, context, schema.not, value));
|
|
13
14
|
}
|
|
14
|
-
export function BuildNot(context, schema, value) {
|
|
15
|
-
return context.UseUnevaluated() ? BuildNotUnevaluated(context, schema, value) : BuildNotFast(context, schema, value);
|
|
15
|
+
export function BuildNot(stack, context, schema, value) {
|
|
16
|
+
return context.UseUnevaluated() ? BuildNotUnevaluated(stack, context, schema, value) : BuildNotFast(stack, context, schema, value);
|
|
16
17
|
}
|
|
17
18
|
// ------------------------------------------------------------------
|
|
18
19
|
// Check
|
|
19
20
|
// ------------------------------------------------------------------
|
|
20
|
-
export function CheckNot(context, schema, value) {
|
|
21
|
-
const
|
|
22
|
-
const isSchema = !CheckSchema(
|
|
23
|
-
const isNot = isSchema && context.Merge([
|
|
21
|
+
export function CheckNot(stack, context, schema, value) {
|
|
22
|
+
const nextContext = new CheckContext();
|
|
23
|
+
const isSchema = !CheckSchema(stack, nextContext, schema.not, value);
|
|
24
|
+
const isNot = isSchema && context.Merge([nextContext]);
|
|
24
25
|
return isNot;
|
|
25
26
|
}
|
|
26
27
|
// ------------------------------------------------------------------
|
|
27
28
|
// Error
|
|
28
29
|
// ------------------------------------------------------------------
|
|
29
|
-
export function ErrorNot(context, schemaPath, instancePath, schema, value) {
|
|
30
|
-
return CheckNot(context, schema, value) || context.AddError({
|
|
30
|
+
export function ErrorNot(stack, context, schemaPath, instancePath, schema, value) {
|
|
31
|
+
return CheckNot(stack, context, schema, value) || context.AddError({
|
|
31
32
|
keyword: 'not',
|
|
32
33
|
schemaPath,
|
|
33
34
|
instancePath,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import * as
|
|
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 BuildOneOf(context: BuildContext, schema:
|
|
4
|
-
export declare function CheckOneOf(context: CheckContext, schema:
|
|
5
|
-
export declare function ErrorOneOf(context: ErrorContext, schemaPath: string, instancePath: string, schema:
|
|
4
|
+
export declare function BuildOneOf(stack: Stack, context: BuildContext, schema: Schema.XOneOf, value: string): string;
|
|
5
|
+
export declare function CheckOneOf(stack: Stack, context: CheckContext, schema: Schema.XOneOf, value: unknown): boolean;
|
|
6
|
+
export declare function ErrorOneOf(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XOneOf, value: unknown): boolean;
|
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
|
+
import { CheckContext, AccumulatedErrorContext } from './_context.mjs';
|
|
3
|
+
import { Reducer } from './_reducer.mjs';
|
|
2
4
|
import { EmitGuard as E, Guard as G } from '../../guard/index.mjs';
|
|
3
|
-
import { AccumulatedErrorContext } from './_context.mjs';
|
|
4
5
|
import { BuildSchema, CheckSchema, ErrorSchema } from './schema.mjs';
|
|
5
|
-
import { Reducer } from './_reducer.mjs';
|
|
6
6
|
// ------------------------------------------------------------------
|
|
7
7
|
// Build
|
|
8
8
|
// ------------------------------------------------------------------
|
|
9
|
-
function BuildOneOfUnevaluated(context, schema, value) {
|
|
10
|
-
return Reducer(context, schema.oneOf, value, E.IsEqual(E.Member('results', 'length'), E.Constant(1)));
|
|
9
|
+
function BuildOneOfUnevaluated(stack, context, schema, value) {
|
|
10
|
+
return Reducer(stack, context, schema.oneOf, value, E.IsEqual(E.Member('results', 'length'), E.Constant(1)));
|
|
11
11
|
}
|
|
12
|
-
function BuildOneOfFast(context, schema, value) {
|
|
13
|
-
const results = E.ArrayLiteral(schema.oneOf.map((schema) => BuildSchema(context, schema, value)));
|
|
12
|
+
function BuildOneOfFast(stack, context, schema, value) {
|
|
13
|
+
const results = E.ArrayLiteral(schema.oneOf.map((schema) => BuildSchema(stack, context, schema, value)));
|
|
14
14
|
const count = E.Call(E.Member(results, 'reduce'), [
|
|
15
15
|
E.ArrowFunction(['count', 'result'], E.Ternary(E.IsEqual('result', E.Constant(true)), E.PrefixIncrement('count'), 'count')),
|
|
16
16
|
E.Constant(0),
|
|
17
17
|
]);
|
|
18
18
|
return E.IsEqual(count, E.Constant(1));
|
|
19
19
|
}
|
|
20
|
-
export function BuildOneOf(context, schema, value) {
|
|
21
|
-
return context.UseUnevaluated() ? BuildOneOfUnevaluated(context, schema, value) : BuildOneOfFast(context, schema, value);
|
|
20
|
+
export function BuildOneOf(stack, context, schema, value) {
|
|
21
|
+
return context.UseUnevaluated() ? BuildOneOfUnevaluated(stack, context, schema, value) : BuildOneOfFast(stack, context, schema, value);
|
|
22
22
|
}
|
|
23
23
|
// ------------------------------------------------------------------
|
|
24
24
|
// Check
|
|
25
25
|
// ------------------------------------------------------------------
|
|
26
|
-
export function CheckOneOf(context, schema, value) {
|
|
26
|
+
export function CheckOneOf(stack, context, schema, value) {
|
|
27
27
|
const passedContexts = schema.oneOf.reduce((result, schema) => {
|
|
28
|
-
const nextContext =
|
|
29
|
-
return CheckSchema(nextContext, schema, value) ? [...result, nextContext] : result;
|
|
28
|
+
const nextContext = new CheckContext();
|
|
29
|
+
return CheckSchema(stack, nextContext, schema, value) ? [...result, nextContext] : result;
|
|
30
30
|
}, []);
|
|
31
31
|
return G.IsEqual(passedContexts.length, 1) && context.Merge(passedContexts);
|
|
32
32
|
}
|
|
33
33
|
// ------------------------------------------------------------------
|
|
34
34
|
// Error
|
|
35
35
|
// ------------------------------------------------------------------
|
|
36
|
-
export function ErrorOneOf(context, schemaPath, instancePath, schema, value) {
|
|
36
|
+
export function ErrorOneOf(stack, context, schemaPath, instancePath, schema, value) {
|
|
37
37
|
const failedContexts = [];
|
|
38
38
|
const passingSchemas = [];
|
|
39
39
|
const passedContexts = schema.oneOf.reduce((result, schema, index) => {
|
|
40
|
-
const nextContext = new AccumulatedErrorContext(
|
|
40
|
+
const nextContext = new AccumulatedErrorContext();
|
|
41
41
|
const nextSchemaPath = `${schemaPath}/oneOf/${index}`;
|
|
42
|
-
const isSchema = ErrorSchema(nextContext, nextSchemaPath, instancePath, schema, value);
|
|
42
|
+
const isSchema = ErrorSchema(stack, nextContext, nextSchemaPath, instancePath, schema, value);
|
|
43
43
|
if (isSchema)
|
|
44
44
|
passingSchemas.push(index);
|
|
45
45
|
if (!isSchema)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import * as
|
|
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 BuildPattern(context: BuildContext, schema:
|
|
4
|
-
export declare function CheckPattern(context: CheckContext, schema:
|
|
5
|
-
export declare function ErrorPattern(context: ErrorContext, schemaPath: string, instancePath: string, schema:
|
|
4
|
+
export declare function BuildPattern(stack: Stack, context: BuildContext, schema: Schema.XPattern, value: string): string;
|
|
5
|
+
export declare function CheckPattern(stack: Stack, context: CheckContext, schema: Schema.XPattern, value: string): boolean;
|
|
6
|
+
export declare function ErrorPattern(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XPattern, value: string): boolean;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
|
-
import * as
|
|
2
|
+
import * as Externals from './_externals.mjs';
|
|
3
3
|
import { Guard as G, EmitGuard as E } from '../../guard/index.mjs';
|
|
4
4
|
// ------------------------------------------------------------------
|
|
5
5
|
// Build
|
|
6
6
|
// ------------------------------------------------------------------
|
|
7
|
-
export function BuildPattern(context, schema, value) {
|
|
8
|
-
const regexp =
|
|
7
|
+
export function BuildPattern(stack, context, schema, value) {
|
|
8
|
+
const regexp = Externals.CreateVariable(G.IsString(schema.pattern) ? new RegExp(schema.pattern) : schema.pattern);
|
|
9
9
|
return E.Call(E.Member(regexp, 'test'), [value]);
|
|
10
10
|
}
|
|
11
11
|
// ------------------------------------------------------------------
|
|
12
12
|
// Check
|
|
13
13
|
// ------------------------------------------------------------------
|
|
14
|
-
export function CheckPattern(context, schema, value) {
|
|
14
|
+
export function CheckPattern(stack, context, schema, value) {
|
|
15
15
|
const regexp = G.IsString(schema.pattern) ? new RegExp(schema.pattern) : schema.pattern;
|
|
16
16
|
return regexp.test(value);
|
|
17
17
|
}
|
|
18
18
|
// ------------------------------------------------------------------
|
|
19
19
|
// Error
|
|
20
20
|
// ------------------------------------------------------------------
|
|
21
|
-
export function ErrorPattern(context, schemaPath, instancePath, schema, value) {
|
|
22
|
-
return CheckPattern(context, schema, value) || context.AddError({
|
|
21
|
+
export function ErrorPattern(stack, context, schemaPath, instancePath, schema, value) {
|
|
22
|
+
return CheckPattern(stack, context, schema, value) || context.AddError({
|
|
23
23
|
keyword: 'pattern',
|
|
24
24
|
schemaPath,
|
|
25
25
|
instancePath,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import * as
|
|
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 BuildPatternProperties(context: BuildContext, schema:
|
|
4
|
-
export declare function CheckPatternProperties(context: CheckContext, schema:
|
|
5
|
-
export declare function ErrorPatternProperties(context: ErrorContext, schemaPath: string, instancePath: string, schema:
|
|
4
|
+
export declare function BuildPatternProperties(stack: Stack, context: BuildContext, schema: Schema.XPatternProperties, value: string): string;
|
|
5
|
+
export declare function CheckPatternProperties(stack: Stack, context: CheckContext, schema: Schema.XPatternProperties, value: Record<PropertyKey, unknown>): boolean;
|
|
6
|
+
export declare function ErrorPatternProperties(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XPatternProperties, value: Record<PropertyKey, unknown>): boolean;
|
|
@@ -1,42 +1,44 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
|
-
import * as
|
|
2
|
+
import * as Externals from './_externals.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, ErrorSchema } from './schema.mjs';
|
|
5
6
|
// ------------------------------------------------------------------
|
|
6
7
|
// Build
|
|
7
8
|
// ------------------------------------------------------------------
|
|
8
|
-
export function BuildPatternProperties(context, schema, value) {
|
|
9
|
+
export function BuildPatternProperties(stack, context, schema, value) {
|
|
9
10
|
return E.ReduceAnd(G.Entries(schema.patternProperties).map(([pattern, schema]) => {
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
11
|
+
const [key, prop] = [Unique(), Unique()];
|
|
12
|
+
const regexp = Externals.CreateVariable(new RegExp(pattern));
|
|
13
|
+
const notKey = E.Not(E.Call(E.Member(regexp, 'test'), [key]));
|
|
14
|
+
const isSchema = BuildSchema(stack, context, schema, prop);
|
|
15
|
+
const addKey = context.AddKey(key);
|
|
14
16
|
const guarded = context.UseUnevaluated() ? E.Or(notKey, E.And(isSchema, addKey)) : E.Or(notKey, isSchema);
|
|
15
|
-
return E.Every(E.Entries(value), E.Constant(0), [
|
|
17
|
+
return E.Every(E.Entries(value), E.Constant(0), [`[${key}, ${prop}]`, '_'], guarded);
|
|
16
18
|
}));
|
|
17
19
|
}
|
|
18
20
|
// ------------------------------------------------------------------
|
|
19
21
|
// Check
|
|
20
22
|
// ------------------------------------------------------------------
|
|
21
|
-
export function CheckPatternProperties(context, schema, value) {
|
|
23
|
+
export function CheckPatternProperties(stack, context, schema, value) {
|
|
22
24
|
return G.Every(G.Entries(schema.patternProperties), 0, ([pattern, schema]) => {
|
|
23
25
|
const regexp = new RegExp(pattern);
|
|
24
|
-
return G.Every(G.Entries(value), 0, ([key,
|
|
25
|
-
return !regexp.test(key) || CheckSchema(context, schema,
|
|
26
|
+
return G.Every(G.Entries(value), 0, ([key, prop]) => {
|
|
27
|
+
return !regexp.test(key) || CheckSchema(stack, context, schema, prop) && context.AddKey(key);
|
|
26
28
|
});
|
|
27
29
|
});
|
|
28
30
|
}
|
|
29
31
|
// ------------------------------------------------------------------
|
|
30
32
|
// Error
|
|
31
33
|
// ------------------------------------------------------------------
|
|
32
|
-
export function ErrorPatternProperties(context, schemaPath, instancePath, schema, value) {
|
|
34
|
+
export function ErrorPatternProperties(stack, context, schemaPath, instancePath, schema, value) {
|
|
33
35
|
return G.EveryAll(G.Entries(schema.patternProperties), 0, ([pattern, schema]) => {
|
|
34
36
|
const nextSchemaPath = `${schemaPath}/patternProperties/${pattern}`;
|
|
35
37
|
const regexp = new RegExp(pattern);
|
|
36
38
|
return G.EveryAll(G.Entries(value), 0, ([key, value]) => {
|
|
37
39
|
const nextInstancePath = `${instancePath}/${key}`;
|
|
38
40
|
const notKey = !regexp.test(key);
|
|
39
|
-
return notKey || ErrorSchema(context, nextSchemaPath, nextInstancePath, schema, value) && context.AddKey(key);
|
|
41
|
+
return notKey || ErrorSchema(stack, context, nextSchemaPath, nextInstancePath, schema, value) && context.AddKey(key);
|
|
40
42
|
});
|
|
41
43
|
});
|
|
42
44
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import * as
|
|
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 BuildPrefixItems(context: BuildContext, schema:
|
|
4
|
-
export declare function CheckPrefixItems(context: CheckContext, schema:
|
|
5
|
-
export declare function ErrorPrefixItems(context: ErrorContext, schemaPath: string, instancePath: string, schema:
|
|
4
|
+
export declare function BuildPrefixItems(stack: Stack, context: BuildContext, schema: Schema.XPrefixItems, value: string): string;
|
|
5
|
+
export declare function CheckPrefixItems(stack: Stack, context: CheckContext, schema: Schema.XPrefixItems, value: unknown[]): boolean;
|
|
6
|
+
export declare function ErrorPrefixItems(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XPrefixItems, value: unknown[]): boolean;
|
|
@@ -4,10 +4,10 @@ import { BuildSchema, CheckSchema, ErrorSchema } from './schema.mjs';
|
|
|
4
4
|
// ------------------------------------------------------------------
|
|
5
5
|
// Build
|
|
6
6
|
// ------------------------------------------------------------------
|
|
7
|
-
export function BuildPrefixItems(context, schema, value) {
|
|
7
|
+
export function BuildPrefixItems(stack, context, schema, value) {
|
|
8
8
|
return E.ReduceAnd(schema.prefixItems.map((schema, index) => {
|
|
9
9
|
const isLength = E.IsLessEqualThan(E.Member(value, 'length'), E.Constant(index));
|
|
10
|
-
const isSchema = BuildSchema(context, schema, `${value}[${index}]`);
|
|
10
|
+
const isSchema = BuildSchema(stack, context, schema, `${value}[${index}]`);
|
|
11
11
|
const addIndex = context.AddIndex(E.Constant(index));
|
|
12
12
|
const guarded = context.UseUnevaluated() ? E.And(isSchema, addIndex) : isSchema;
|
|
13
13
|
return E.Or(isLength, guarded);
|
|
@@ -16,20 +16,20 @@ export function BuildPrefixItems(context, schema, value) {
|
|
|
16
16
|
// ------------------------------------------------------------------
|
|
17
17
|
// Check
|
|
18
18
|
// ------------------------------------------------------------------
|
|
19
|
-
export function CheckPrefixItems(context, schema, value) {
|
|
19
|
+
export function CheckPrefixItems(stack, context, schema, value) {
|
|
20
20
|
return G.IsEqual(value.length, 0) || G.Every(schema.prefixItems, 0, (schema, index) => {
|
|
21
21
|
return G.IsLessEqualThan(value.length, index)
|
|
22
|
-
|| (CheckSchema(context, schema, value[index]) && context.AddIndex(index));
|
|
22
|
+
|| (CheckSchema(stack, context, schema, value[index]) && context.AddIndex(index));
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
// ------------------------------------------------------------------
|
|
26
26
|
// Error
|
|
27
27
|
// ------------------------------------------------------------------
|
|
28
|
-
export function ErrorPrefixItems(context, schemaPath, instancePath, schema, value) {
|
|
28
|
+
export function ErrorPrefixItems(stack, context, schemaPath, instancePath, schema, value) {
|
|
29
29
|
return G.IsEqual(value.length, 0) || G.EveryAll(schema.prefixItems, 0, (schema, index) => {
|
|
30
30
|
const nextSchemaPath = `${schemaPath}/prefixItems/${index}`;
|
|
31
31
|
const nextInstancePath = `${instancePath}/${index}`;
|
|
32
32
|
return G.IsLessEqualThan(value.length, index)
|
|
33
|
-
|| (ErrorSchema(context, nextSchemaPath, nextInstancePath, schema, value[index]) && context.AddIndex(index));
|
|
33
|
+
|| (ErrorSchema(stack, context, nextSchemaPath, nextInstancePath, schema, value[index]) && context.AddIndex(index));
|
|
34
34
|
});
|
|
35
35
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import * as
|
|
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 BuildProperties(context: BuildContext, schema:
|
|
4
|
-
export declare function CheckProperties(context: CheckContext, schema:
|
|
5
|
-
export declare function ErrorProperties(context: ErrorContext, schemaPath: string, instancePath: string, schema:
|
|
4
|
+
export declare function BuildProperties(stack: Stack, context: BuildContext, schema: Schema.XProperties, value: string): string;
|
|
5
|
+
export declare function CheckProperties(stack: Stack, context: CheckContext, schema: Schema.XProperties, value: Record<PropertyKey, unknown>): boolean;
|
|
6
|
+
export declare function ErrorProperties(stack: Stack, context: ErrorContext, schemaPath: string, instancePath: string, schema: Schema.XProperties, value: Record<PropertyKey, unknown>): boolean;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
|
+
import * as Schema from '../types/index.mjs';
|
|
2
3
|
import { Guard as G, EmitGuard as E } from '../../guard/index.mjs';
|
|
3
|
-
import * as S from '../types/index.mjs';
|
|
4
4
|
import { BuildSchema, CheckSchema, ErrorSchema } from './schema.mjs';
|
|
5
5
|
import { InexactOptionalCheck, InexactOptionalBuild, IsExactOptional } from './_exact_optional.mjs';
|
|
6
6
|
// ------------------------------------------------------------------
|
|
7
7
|
// Build
|
|
8
8
|
// ------------------------------------------------------------------
|
|
9
|
-
export function BuildProperties(context, schema, value) {
|
|
10
|
-
const required =
|
|
9
|
+
export function BuildProperties(stack, context, schema, value) {
|
|
10
|
+
const required = Schema.IsRequired(schema) ? schema.required : [];
|
|
11
11
|
const everyKey = G.Entries(schema.properties).map(([key, schema]) => {
|
|
12
12
|
const notKey = E.Not(E.HasPropertyKey(value, E.Constant(key)));
|
|
13
|
-
const isSchema = BuildSchema(context, schema, E.Member(value, key));
|
|
13
|
+
const isSchema = BuildSchema(stack, context, schema, E.Member(value, key));
|
|
14
14
|
const addKey = context.AddKey(E.Constant(key));
|
|
15
15
|
const guarded = context.UseUnevaluated() ? E.And(isSchema, addKey) : isSchema;
|
|
16
16
|
// --------------------------------------------------------------
|
|
@@ -47,10 +47,10 @@ export function BuildProperties(context, schema, value) {
|
|
|
47
47
|
// ------------------------------------------------------------------
|
|
48
48
|
// Check
|
|
49
49
|
// ------------------------------------------------------------------
|
|
50
|
-
export function CheckProperties(context, schema, value) {
|
|
51
|
-
const required =
|
|
50
|
+
export function CheckProperties(stack, context, schema, value) {
|
|
51
|
+
const required = Schema.IsRequired(schema) ? schema.required : [];
|
|
52
52
|
const isProperties = G.Every(G.Entries(schema.properties), 0, ([key, schema]) => {
|
|
53
|
-
const isProperty = !G.HasPropertyKey(value, key) || (CheckSchema(context, schema, value[key]) && context.AddKey(key));
|
|
53
|
+
const isProperty = !G.HasPropertyKey(value, key) || (CheckSchema(stack, context, schema, value[key]) && context.AddKey(key));
|
|
54
54
|
return IsExactOptional(required, key)
|
|
55
55
|
? isProperty
|
|
56
56
|
: InexactOptionalCheck(value, key) || isProperty;
|
|
@@ -60,13 +60,13 @@ export function CheckProperties(context, schema, value) {
|
|
|
60
60
|
// ------------------------------------------------------------------
|
|
61
61
|
// Error
|
|
62
62
|
// ------------------------------------------------------------------
|
|
63
|
-
export function ErrorProperties(context, schemaPath, instancePath, schema, value) {
|
|
64
|
-
const required =
|
|
63
|
+
export function ErrorProperties(stack, context, schemaPath, instancePath, schema, value) {
|
|
64
|
+
const required = Schema.IsRequired(schema) ? schema.required : [];
|
|
65
65
|
const isProperties = G.EveryAll(G.Entries(schema.properties), 0, ([key, schema]) => {
|
|
66
66
|
const nextSchemaPath = `${schemaPath}/properties/${key}`;
|
|
67
67
|
const nextInstancePath = `${instancePath}/${key}`;
|
|
68
68
|
// Defer error generation for IsExactOptional
|
|
69
|
-
const isProperty = () => (!G.HasPropertyKey(value, key) || (ErrorSchema(context, nextSchemaPath, nextInstancePath, schema, value[key]) && context.AddKey(key)));
|
|
69
|
+
const isProperty = () => (!G.HasPropertyKey(value, key) || (ErrorSchema(stack, context, nextSchemaPath, nextInstancePath, schema, value[key]) && context.AddKey(key)));
|
|
70
70
|
return IsExactOptional(required, key)
|
|
71
71
|
? isProperty()
|
|
72
72
|
: InexactOptionalCheck(value, key) || isProperty();
|