@sinclair/typebox 0.32.0-dev-4 → 0.32.0-dev-5
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/import/compiler/compiler.mjs +571 -0
- package/build/import/compiler/index.mjs +2 -0
- package/build/import/errors/errors.mjs +531 -0
- package/build/import/errors/index.mjs +1 -0
- package/build/import/index.mjs +69 -0
- package/build/import/system/errors.mjs +150 -0
- package/build/import/system/index.mjs +4 -0
- package/build/import/system/policy.mjs +31 -0
- package/build/import/system/system.mjs +30 -0
- package/build/import/type/any/any.mjs +4 -0
- package/build/import/type/any/index.mjs +1 -0
- package/build/import/type/array/array.mjs +10 -0
- package/build/import/type/array/index.mjs +1 -0
- package/build/import/type/async-iterator/async-iterator.mjs +10 -0
- package/build/import/type/async-iterator/index.mjs +1 -0
- package/build/import/type/awaited/awaited.mjs +28 -0
- package/build/import/type/awaited/index.mjs +1 -0
- package/build/import/type/bigint/bigint.mjs +8 -0
- package/build/import/type/bigint/index.mjs +1 -0
- package/build/import/type/boolean/boolean.mjs +8 -0
- package/build/import/type/boolean/index.mjs +1 -0
- package/build/import/type/clone/index.mjs +2 -0
- package/build/import/type/clone/type.mjs +7 -0
- package/build/import/type/clone/value.mjs +25 -0
- package/build/import/type/composite/composite.mjs +14 -0
- package/build/import/type/composite/index.mjs +1 -0
- package/build/import/type/const/const.mjs +49 -0
- package/build/import/type/const/index.mjs +1 -0
- package/build/import/type/constructor/constructor.mjs +11 -0
- package/build/import/type/constructor/index.mjs +1 -0
- package/build/import/type/constructor-parameters/constructor-parameters.mjs +5 -0
- package/build/import/type/constructor-parameters/index.mjs +1 -0
- package/build/import/type/date/date.mjs +8 -0
- package/build/import/type/date/index.mjs +1 -0
- package/build/import/type/deref/deref.mjs +90 -0
- package/build/import/type/deref/index.mjs +1 -0
- package/build/import/type/discard/discard.mjs +7 -0
- package/build/import/type/discard/index.mjs +1 -0
- package/build/import/type/enum/enum.mjs +14 -0
- package/build/import/type/enum/index.mjs +1 -0
- package/build/import/type/exclude/exclude.mjs +20 -0
- package/build/import/type/exclude/index.mjs +1 -0
- package/build/import/type/extends/extends-check.mjs +450 -0
- package/build/import/type/extends/extends-undefined.mjs +17 -0
- package/build/import/type/extends/extends.mjs +13 -0
- package/build/import/type/extends/index.mjs +3 -0
- package/build/import/type/extract/extract.mjs +20 -0
- package/build/import/type/extract/index.mjs +1 -0
- package/build/import/type/function/function.mjs +11 -0
- package/build/import/type/function/index.mjs +1 -0
- package/build/import/type/guard/index.mjs +2 -0
- package/build/import/type/guard/type.mjs +366 -0
- package/build/import/type/guard/value.mjs +42 -0
- package/build/import/type/helpers/helpers.mjs +3 -0
- package/build/import/type/helpers/index.mjs +1 -0
- package/build/import/type/index.mjs +70 -0
- package/build/import/type/indexed/index.mjs +3 -0
- package/build/import/type/indexed/indexed-key.mjs +29 -0
- package/build/import/type/indexed/indexed-type.mjs +64 -0
- package/build/import/type/indexed/indexed.mjs +9 -0
- package/build/import/type/instance-type/index.mjs +1 -0
- package/build/import/type/instance-type/instance-type.mjs +4 -0
- package/build/import/type/integer/index.mjs +1 -0
- package/build/import/type/integer/integer.mjs +8 -0
- package/build/import/type/intersect/index.mjs +1 -0
- package/build/import/type/intersect/intersect.mjs +25 -0
- package/build/import/type/intrinsic/index.mjs +1 -0
- package/build/import/type/intrinsic/intrinsic.mjs +59 -0
- package/build/import/type/iterator/index.mjs +1 -0
- package/build/import/type/iterator/iterator.mjs +10 -0
- package/build/import/type/keyof/index.mjs +3 -0
- package/build/import/type/keyof/keyof-string.mjs +55 -0
- package/build/import/type/keyof/keyof-type.mjs +15 -0
- package/build/import/type/keyof/keyof.mjs +6 -0
- package/build/import/type/literal/index.mjs +1 -0
- package/build/import/type/literal/literal.mjs +9 -0
- package/build/import/type/mapped/index.mjs +1 -0
- package/build/import/type/mapped/mapped.mjs +14 -0
- package/build/import/type/modifiers/index.mjs +1 -0
- package/build/import/type/modifiers/modifiers.mjs +40 -0
- package/build/import/type/never/index.mjs +1 -0
- package/build/import/type/never/never.mjs +8 -0
- package/build/import/type/not/index.mjs +1 -0
- package/build/import/type/not/not.mjs +9 -0
- package/build/import/type/null/index.mjs +1 -0
- package/build/import/type/null/null.mjs +8 -0
- package/build/import/type/number/index.mjs +1 -0
- package/build/import/type/number/number.mjs +8 -0
- package/build/import/type/object/index.mjs +1 -0
- package/build/import/type/object/object.mjs +14 -0
- package/build/import/type/omit/index.mjs +1 -0
- package/build/import/type/omit/omit.mjs +35 -0
- package/build/import/type/operators/index.mjs +1 -0
- package/build/import/type/operators/operators.mjs +66 -0
- package/build/import/type/optional/index.mjs +1 -0
- package/build/import/type/optional/optional.mjs +5 -0
- package/build/import/type/parameters/index.mjs +1 -0
- package/build/import/type/parameters/parameters.mjs +5 -0
- package/build/import/type/partial/index.mjs +1 -0
- package/build/import/type/partial/partial.mjs +36 -0
- package/build/import/type/patterns/index.mjs +1 -0
- package/build/import/type/patterns/patterns.mjs +6 -0
- package/build/import/type/pick/index.mjs +1 -0
- package/build/import/type/pick/pick.mjs +31 -0
- package/build/import/type/promise/index.mjs +1 -0
- package/build/import/type/promise/promise.mjs +10 -0
- package/build/import/type/readonly/index.mjs +1 -0
- package/build/import/type/readonly/readonly.mjs +5 -0
- package/build/import/type/readonly-optional/index.mjs +1 -0
- package/build/import/type/readonly-optional/readonly-optional.mjs +5 -0
- package/build/import/type/record/index.mjs +1 -0
- package/build/import/type/record/record.mjs +51 -0
- package/build/import/type/recursive/index.mjs +1 -0
- package/build/import/type/recursive/recursive.mjs +15 -0
- package/build/import/type/ref/index.mjs +1 -0
- package/build/import/type/ref/ref.mjs +13 -0
- package/build/import/type/regexp/index.mjs +1 -0
- package/build/import/type/regexp/regexp.mjs +6 -0
- package/build/import/type/registry/format.mjs +19 -0
- package/build/import/type/registry/index.mjs +2 -0
- package/build/import/type/registry/type.mjs +19 -0
- package/build/import/type/required/index.mjs +1 -0
- package/build/import/type/required/required.mjs +35 -0
- package/build/import/type/rest/index.mjs +1 -0
- package/build/import/type/rest/rest.mjs +8 -0
- package/build/import/type/return-type/index.mjs +1 -0
- package/build/import/type/return-type/return-type.mjs +4 -0
- package/build/import/type/schema/anyschema.mjs +1 -0
- package/build/import/type/schema/index.mjs +2 -0
- package/build/import/type/schema/schema.mjs +1 -0
- package/build/import/type/static/index.mjs +1 -0
- package/build/import/type/static/static.mjs +1 -0
- package/build/import/type/strict/index.mjs +1 -0
- package/build/import/type/strict/strict.mjs +3 -0
- package/build/import/type/string/index.mjs +1 -0
- package/build/import/type/string/string.mjs +4 -0
- package/build/import/type/symbol/index.mjs +1 -0
- package/build/import/type/symbol/symbol.mjs +4 -0
- package/build/import/type/symbols/index.mjs +1 -0
- package/build/import/type/symbols/symbols.mjs +5 -0
- package/build/import/type/template-literal/finite.mjs +29 -0
- package/build/import/type/template-literal/generate.mjs +32 -0
- package/build/import/type/template-literal/index.mjs +7 -0
- package/build/import/type/template-literal/parser.mjs +125 -0
- package/build/import/type/template-literal/pattern.mjs +22 -0
- package/build/import/type/template-literal/syntax.mjs +48 -0
- package/build/import/type/template-literal/template-literal.mjs +10 -0
- package/build/import/type/template-literal/union.mjs +13 -0
- package/build/import/type/transform/index.mjs +1 -0
- package/build/import/type/transform/transform.mjs +37 -0
- package/build/import/type/tuple/index.mjs +1 -0
- package/build/import/type/tuple/tuple.mjs +8 -0
- package/build/import/type/type/index.mjs +6 -0
- package/build/import/type/type/javascript.mjs +71 -0
- package/build/import/type/type/json.mjs +171 -0
- package/build/import/type/type/type.mjs +58 -0
- package/build/import/type/uint8array/index.mjs +1 -0
- package/build/import/type/uint8array/uint8array.mjs +4 -0
- package/build/import/type/undefined/index.mjs +1 -0
- package/build/import/type/undefined/undefined.mjs +4 -0
- package/build/import/type/union/index.mjs +1 -0
- package/build/import/type/union/union.mjs +15 -0
- package/build/import/type/unknown/index.mjs +1 -0
- package/build/import/type/unknown/unknown.mjs +7 -0
- package/build/import/type/unsafe/index.mjs +1 -0
- package/build/import/type/unsafe/unsafe.mjs +7 -0
- package/build/import/type/void/index.mjs +1 -0
- package/build/import/type/void/void.mjs +8 -0
- package/build/import/value/cast/cast.mjs +205 -0
- package/build/import/value/cast/index.mjs +1 -0
- package/build/import/value/check/check.mjs +419 -0
- package/build/import/value/check/index.mjs +1 -0
- package/build/import/value/clean/clean.mjs +125 -0
- package/build/import/value/clean/index.mjs +1 -0
- package/build/import/value/clone/clone.mjs +30 -0
- package/build/import/value/clone/index.mjs +1 -0
- package/build/import/value/convert/convert.mjs +231 -0
- package/build/import/value/convert/index.mjs +1 -0
- package/build/import/value/create/create.mjs +460 -0
- package/build/import/value/create/index.mjs +1 -0
- package/build/import/value/default/default.mjs +125 -0
- package/build/import/value/default/index.mjs +1 -0
- package/build/import/value/delta/delta.mjs +152 -0
- package/build/import/value/delta/index.mjs +1 -0
- package/build/import/value/deref/deref.mjs +13 -0
- package/build/import/value/deref/index.mjs +1 -0
- package/build/import/value/equal/equal.mjs +39 -0
- package/build/import/value/equal/index.mjs +1 -0
- package/build/import/value/guard/guard.mjs +66 -0
- package/build/import/value/guard/index.mjs +1 -0
- package/build/import/value/hash/hash.mjs +127 -0
- package/build/import/value/hash/index.mjs +1 -0
- package/build/import/value/index.mjs +18 -0
- package/build/import/value/mutate/index.mjs +1 -0
- package/build/import/value/mutate/mutate.mjs +85 -0
- package/build/import/value/pointer/index.mjs +1 -0
- package/build/import/value/pointer/pointer.mjs +101 -0
- package/build/import/value/transform/decode.mjs +160 -0
- package/build/import/value/transform/encode.mjs +166 -0
- package/build/import/value/transform/has.mjs +99 -0
- package/build/import/value/transform/index.mjs +3 -0
- package/build/import/value/value/index.mjs +1 -0
- package/build/import/value/value/value.mjs +65 -0
- package/compiler/package.json +4 -0
- package/errors/package.json +4 -0
- package/package.json +52 -53
- package/system/package.json +4 -0
- package/type/package.json +4 -0
- package/value/package.json +4 -0
- /package/{compiler → build/default/compiler}/compiler.js +0 -0
- /package/{compiler → build/default/compiler}/index.js +0 -0
- /package/{errors → build/default/errors}/errors.js +0 -0
- /package/{errors → build/default/errors}/index.js +0 -0
- /package/{index.js → build/default/index.js} +0 -0
- /package/{system → build/default/system}/errors.js +0 -0
- /package/{system → build/default/system}/index.js +0 -0
- /package/{system → build/default/system}/policy.js +0 -0
- /package/{system → build/default/system}/system.js +0 -0
- /package/{type → build/default/type}/any/any.js +0 -0
- /package/{type → build/default/type}/any/index.js +0 -0
- /package/{type → build/default/type}/array/array.js +0 -0
- /package/{type → build/default/type}/array/index.js +0 -0
- /package/{type → build/default/type}/async-iterator/async-iterator.js +0 -0
- /package/{type → build/default/type}/async-iterator/index.js +0 -0
- /package/{type → build/default/type}/awaited/awaited.js +0 -0
- /package/{type → build/default/type}/awaited/index.js +0 -0
- /package/{type → build/default/type}/bigint/bigint.js +0 -0
- /package/{type → build/default/type}/bigint/index.js +0 -0
- /package/{type → build/default/type}/boolean/boolean.js +0 -0
- /package/{type → build/default/type}/boolean/index.js +0 -0
- /package/{type → build/default/type}/clone/index.js +0 -0
- /package/{type → build/default/type}/clone/type.js +0 -0
- /package/{type → build/default/type}/clone/value.js +0 -0
- /package/{type → build/default/type}/composite/composite.js +0 -0
- /package/{type → build/default/type}/composite/index.js +0 -0
- /package/{type → build/default/type}/const/const.js +0 -0
- /package/{type → build/default/type}/const/index.js +0 -0
- /package/{type → build/default/type}/constructor/constructor.js +0 -0
- /package/{type → build/default/type}/constructor/index.js +0 -0
- /package/{type → build/default/type}/constructor-parameters/constructor-parameters.js +0 -0
- /package/{type → build/default/type}/constructor-parameters/index.js +0 -0
- /package/{type → build/default/type}/date/date.js +0 -0
- /package/{type → build/default/type}/date/index.js +0 -0
- /package/{type → build/default/type}/deref/deref.js +0 -0
- /package/{type → build/default/type}/deref/index.js +0 -0
- /package/{type → build/default/type}/discard/discard.js +0 -0
- /package/{type → build/default/type}/discard/index.js +0 -0
- /package/{type → build/default/type}/enum/enum.js +0 -0
- /package/{type → build/default/type}/enum/index.js +0 -0
- /package/{type → build/default/type}/exclude/exclude.js +0 -0
- /package/{type → build/default/type}/exclude/index.js +0 -0
- /package/{type → build/default/type}/extends/extends-check.js +0 -0
- /package/{type → build/default/type}/extends/extends-undefined.js +0 -0
- /package/{type → build/default/type}/extends/extends.js +0 -0
- /package/{type → build/default/type}/extends/index.js +0 -0
- /package/{type → build/default/type}/extract/extract.js +0 -0
- /package/{type → build/default/type}/extract/index.js +0 -0
- /package/{type → build/default/type}/function/function.js +0 -0
- /package/{type → build/default/type}/function/index.js +0 -0
- /package/{type → build/default/type}/guard/index.js +0 -0
- /package/{type → build/default/type}/guard/type.js +0 -0
- /package/{type → build/default/type}/guard/value.js +0 -0
- /package/{type → build/default/type}/helpers/helpers.js +0 -0
- /package/{type → build/default/type}/helpers/index.js +0 -0
- /package/{type → build/default/type}/index.js +0 -0
- /package/{type → build/default/type}/indexed/index.js +0 -0
- /package/{type → build/default/type}/indexed/indexed-key.js +0 -0
- /package/{type → build/default/type}/indexed/indexed-type.js +0 -0
- /package/{type → build/default/type}/indexed/indexed.js +0 -0
- /package/{type → build/default/type}/instance-type/index.js +0 -0
- /package/{type → build/default/type}/instance-type/instance-type.js +0 -0
- /package/{type → build/default/type}/integer/index.js +0 -0
- /package/{type → build/default/type}/integer/integer.js +0 -0
- /package/{type → build/default/type}/intersect/index.js +0 -0
- /package/{type → build/default/type}/intersect/intersect.js +0 -0
- /package/{type → build/default/type}/intrinsic/index.js +0 -0
- /package/{type → build/default/type}/intrinsic/intrinsic.js +0 -0
- /package/{type → build/default/type}/iterator/index.js +0 -0
- /package/{type → build/default/type}/iterator/iterator.js +0 -0
- /package/{type → build/default/type}/keyof/index.js +0 -0
- /package/{type → build/default/type}/keyof/keyof-string.js +0 -0
- /package/{type → build/default/type}/keyof/keyof-type.js +0 -0
- /package/{type → build/default/type}/keyof/keyof.js +0 -0
- /package/{type → build/default/type}/literal/index.js +0 -0
- /package/{type → build/default/type}/literal/literal.js +0 -0
- /package/{type → build/default/type}/mapped/index.js +0 -0
- /package/{type → build/default/type}/mapped/mapped.js +0 -0
- /package/{type → build/default/type}/modifiers/index.js +0 -0
- /package/{type → build/default/type}/modifiers/modifiers.js +0 -0
- /package/{type → build/default/type}/never/index.js +0 -0
- /package/{type → build/default/type}/never/never.js +0 -0
- /package/{type → build/default/type}/not/index.js +0 -0
- /package/{type → build/default/type}/not/not.js +0 -0
- /package/{type → build/default/type}/null/index.js +0 -0
- /package/{type → build/default/type}/null/null.js +0 -0
- /package/{type → build/default/type}/number/index.js +0 -0
- /package/{type → build/default/type}/number/number.js +0 -0
- /package/{type → build/default/type}/object/index.js +0 -0
- /package/{type → build/default/type}/object/object.js +0 -0
- /package/{type → build/default/type}/omit/index.js +0 -0
- /package/{type → build/default/type}/omit/omit.js +0 -0
- /package/{type → build/default/type}/operators/index.js +0 -0
- /package/{type → build/default/type}/operators/operators.js +0 -0
- /package/{type → build/default/type}/optional/index.js +0 -0
- /package/{type → build/default/type}/optional/optional.js +0 -0
- /package/{type → build/default/type}/parameters/index.js +0 -0
- /package/{type → build/default/type}/parameters/parameters.js +0 -0
- /package/{type → build/default/type}/partial/index.js +0 -0
- /package/{type → build/default/type}/partial/partial.js +0 -0
- /package/{type → build/default/type}/patterns/index.js +0 -0
- /package/{type → build/default/type}/patterns/patterns.js +0 -0
- /package/{type → build/default/type}/pick/index.js +0 -0
- /package/{type → build/default/type}/pick/pick.js +0 -0
- /package/{type → build/default/type}/promise/index.js +0 -0
- /package/{type → build/default/type}/promise/promise.js +0 -0
- /package/{type → build/default/type}/readonly/index.js +0 -0
- /package/{type → build/default/type}/readonly/readonly.js +0 -0
- /package/{type → build/default/type}/readonly-optional/index.js +0 -0
- /package/{type → build/default/type}/readonly-optional/readonly-optional.js +0 -0
- /package/{type → build/default/type}/record/index.js +0 -0
- /package/{type → build/default/type}/record/record.js +0 -0
- /package/{type → build/default/type}/recursive/index.js +0 -0
- /package/{type → build/default/type}/recursive/recursive.js +0 -0
- /package/{type → build/default/type}/ref/index.js +0 -0
- /package/{type → build/default/type}/ref/ref.js +0 -0
- /package/{type → build/default/type}/regexp/index.js +0 -0
- /package/{type → build/default/type}/regexp/regexp.js +0 -0
- /package/{type → build/default/type}/registry/format.js +0 -0
- /package/{type → build/default/type}/registry/index.js +0 -0
- /package/{type → build/default/type}/registry/type.js +0 -0
- /package/{type → build/default/type}/required/index.js +0 -0
- /package/{type → build/default/type}/required/required.js +0 -0
- /package/{type → build/default/type}/rest/index.js +0 -0
- /package/{type → build/default/type}/rest/rest.js +0 -0
- /package/{type → build/default/type}/return-type/index.js +0 -0
- /package/{type → build/default/type}/return-type/return-type.js +0 -0
- /package/{type → build/default/type}/schema/anyschema.js +0 -0
- /package/{type → build/default/type}/schema/index.js +0 -0
- /package/{type → build/default/type}/schema/schema.js +0 -0
- /package/{type → build/default/type}/static/index.js +0 -0
- /package/{type → build/default/type}/static/static.js +0 -0
- /package/{type → build/default/type}/strict/index.js +0 -0
- /package/{type → build/default/type}/strict/strict.js +0 -0
- /package/{type → build/default/type}/string/index.js +0 -0
- /package/{type → build/default/type}/string/string.js +0 -0
- /package/{type → build/default/type}/symbol/index.js +0 -0
- /package/{type → build/default/type}/symbol/symbol.js +0 -0
- /package/{type → build/default/type}/symbols/index.js +0 -0
- /package/{type → build/default/type}/symbols/symbols.js +0 -0
- /package/{type → build/default/type}/template-literal/finite.js +0 -0
- /package/{type → build/default/type}/template-literal/generate.js +0 -0
- /package/{type → build/default/type}/template-literal/index.js +0 -0
- /package/{type → build/default/type}/template-literal/parser.js +0 -0
- /package/{type → build/default/type}/template-literal/pattern.js +0 -0
- /package/{type → build/default/type}/template-literal/syntax.js +0 -0
- /package/{type → build/default/type}/template-literal/template-literal.js +0 -0
- /package/{type → build/default/type}/template-literal/union.js +0 -0
- /package/{type → build/default/type}/transform/index.js +0 -0
- /package/{type → build/default/type}/transform/transform.js +0 -0
- /package/{type → build/default/type}/tuple/index.js +0 -0
- /package/{type → build/default/type}/tuple/tuple.js +0 -0
- /package/{type → build/default/type}/type/index.js +0 -0
- /package/{type → build/default/type}/type/javascript.js +0 -0
- /package/{type → build/default/type}/type/json.js +0 -0
- /package/{type → build/default/type}/type/type.js +0 -0
- /package/{type → build/default/type}/uint8array/index.js +0 -0
- /package/{type → build/default/type}/uint8array/uint8array.js +0 -0
- /package/{type → build/default/type}/undefined/index.js +0 -0
- /package/{type → build/default/type}/undefined/undefined.js +0 -0
- /package/{type → build/default/type}/union/index.js +0 -0
- /package/{type → build/default/type}/union/union.js +0 -0
- /package/{type → build/default/type}/unknown/index.js +0 -0
- /package/{type → build/default/type}/unknown/unknown.js +0 -0
- /package/{type → build/default/type}/unsafe/index.js +0 -0
- /package/{type → build/default/type}/unsafe/unsafe.js +0 -0
- /package/{type → build/default/type}/void/index.js +0 -0
- /package/{type → build/default/type}/void/void.js +0 -0
- /package/{value → build/default/value}/cast/cast.js +0 -0
- /package/{value → build/default/value}/cast/index.js +0 -0
- /package/{value → build/default/value}/check/check.js +0 -0
- /package/{value → build/default/value}/check/index.js +0 -0
- /package/{value → build/default/value}/clean/clean.js +0 -0
- /package/{value → build/default/value}/clean/index.js +0 -0
- /package/{value → build/default/value}/clone/clone.js +0 -0
- /package/{value → build/default/value}/clone/index.js +0 -0
- /package/{value → build/default/value}/convert/convert.js +0 -0
- /package/{value → build/default/value}/convert/index.js +0 -0
- /package/{value → build/default/value}/create/create.js +0 -0
- /package/{value → build/default/value}/create/index.js +0 -0
- /package/{value → build/default/value}/default/default.js +0 -0
- /package/{value → build/default/value}/default/index.js +0 -0
- /package/{value → build/default/value}/delta/delta.js +0 -0
- /package/{value → build/default/value}/delta/index.js +0 -0
- /package/{value → build/default/value}/deref/deref.js +0 -0
- /package/{value → build/default/value}/deref/index.js +0 -0
- /package/{value → build/default/value}/equal/equal.js +0 -0
- /package/{value → build/default/value}/equal/index.js +0 -0
- /package/{value → build/default/value}/guard/guard.js +0 -0
- /package/{value → build/default/value}/guard/index.js +0 -0
- /package/{value → build/default/value}/hash/hash.js +0 -0
- /package/{value → build/default/value}/hash/index.js +0 -0
- /package/{value → build/default/value}/index.js +0 -0
- /package/{value → build/default/value}/mutate/index.js +0 -0
- /package/{value → build/default/value}/mutate/mutate.js +0 -0
- /package/{value → build/default/value}/pointer/index.js +0 -0
- /package/{value → build/default/value}/pointer/pointer.js +0 -0
- /package/{value → build/default/value}/transform/decode.js +0 -0
- /package/{value → build/default/value}/transform/encode.js +0 -0
- /package/{value → build/default/value}/transform/has.js +0 -0
- /package/{value → build/default/value}/transform/index.js +0 -0
- /package/{value → build/default/value}/value/index.js +0 -0
- /package/{value → build/default/value}/value/value.js +0 -0
- /package/{compiler → build/types/compiler}/compiler.d.ts +0 -0
- /package/{compiler → build/types/compiler}/index.d.ts +0 -0
- /package/{errors → build/types/errors}/errors.d.ts +0 -0
- /package/{errors → build/types/errors}/index.d.ts +0 -0
- /package/{index.d.ts → build/types/index.d.ts} +0 -0
- /package/{system → build/types/system}/errors.d.ts +0 -0
- /package/{system → build/types/system}/index.d.ts +0 -0
- /package/{system → build/types/system}/policy.d.ts +0 -0
- /package/{system → build/types/system}/system.d.ts +0 -0
- /package/{type → build/types/type}/any/any.d.ts +0 -0
- /package/{type → build/types/type}/any/index.d.ts +0 -0
- /package/{type → build/types/type}/array/array.d.ts +0 -0
- /package/{type → build/types/type}/array/index.d.ts +0 -0
- /package/{type → build/types/type}/async-iterator/async-iterator.d.ts +0 -0
- /package/{type → build/types/type}/async-iterator/index.d.ts +0 -0
- /package/{type → build/types/type}/awaited/awaited.d.ts +0 -0
- /package/{type → build/types/type}/awaited/index.d.ts +0 -0
- /package/{type → build/types/type}/bigint/bigint.d.ts +0 -0
- /package/{type → build/types/type}/bigint/index.d.ts +0 -0
- /package/{type → build/types/type}/boolean/boolean.d.ts +0 -0
- /package/{type → build/types/type}/boolean/index.d.ts +0 -0
- /package/{type → build/types/type}/clone/index.d.ts +0 -0
- /package/{type → build/types/type}/clone/type.d.ts +0 -0
- /package/{type → build/types/type}/clone/value.d.ts +0 -0
- /package/{type → build/types/type}/composite/composite.d.ts +0 -0
- /package/{type → build/types/type}/composite/index.d.ts +0 -0
- /package/{type → build/types/type}/const/const.d.ts +0 -0
- /package/{type → build/types/type}/const/index.d.ts +0 -0
- /package/{type → build/types/type}/constructor/constructor.d.ts +0 -0
- /package/{type → build/types/type}/constructor/index.d.ts +0 -0
- /package/{type → build/types/type}/constructor-parameters/constructor-parameters.d.ts +0 -0
- /package/{type → build/types/type}/constructor-parameters/index.d.ts +0 -0
- /package/{type → build/types/type}/date/date.d.ts +0 -0
- /package/{type → build/types/type}/date/index.d.ts +0 -0
- /package/{type → build/types/type}/deref/deref.d.ts +0 -0
- /package/{type → build/types/type}/deref/index.d.ts +0 -0
- /package/{type → build/types/type}/discard/discard.d.ts +0 -0
- /package/{type → build/types/type}/discard/index.d.ts +0 -0
- /package/{type → build/types/type}/enum/enum.d.ts +0 -0
- /package/{type → build/types/type}/enum/index.d.ts +0 -0
- /package/{type → build/types/type}/exclude/exclude.d.ts +0 -0
- /package/{type → build/types/type}/exclude/index.d.ts +0 -0
- /package/{type → build/types/type}/extends/extends-check.d.ts +0 -0
- /package/{type → build/types/type}/extends/extends-undefined.d.ts +0 -0
- /package/{type → build/types/type}/extends/extends.d.ts +0 -0
- /package/{type → build/types/type}/extends/index.d.ts +0 -0
- /package/{type → build/types/type}/extract/extract.d.ts +0 -0
- /package/{type → build/types/type}/extract/index.d.ts +0 -0
- /package/{type → build/types/type}/function/function.d.ts +0 -0
- /package/{type → build/types/type}/function/index.d.ts +0 -0
- /package/{type → build/types/type}/guard/index.d.ts +0 -0
- /package/{type → build/types/type}/guard/type.d.ts +0 -0
- /package/{type → build/types/type}/guard/value.d.ts +0 -0
- /package/{type → build/types/type}/helpers/helpers.d.ts +0 -0
- /package/{type → build/types/type}/helpers/index.d.ts +0 -0
- /package/{type → build/types/type}/index.d.ts +0 -0
- /package/{type → build/types/type}/indexed/index.d.ts +0 -0
- /package/{type → build/types/type}/indexed/indexed-key.d.ts +0 -0
- /package/{type → build/types/type}/indexed/indexed-type.d.ts +0 -0
- /package/{type → build/types/type}/indexed/indexed.d.ts +0 -0
- /package/{type → build/types/type}/instance-type/index.d.ts +0 -0
- /package/{type → build/types/type}/instance-type/instance-type.d.ts +0 -0
- /package/{type → build/types/type}/integer/index.d.ts +0 -0
- /package/{type → build/types/type}/integer/integer.d.ts +0 -0
- /package/{type → build/types/type}/intersect/index.d.ts +0 -0
- /package/{type → build/types/type}/intersect/intersect.d.ts +0 -0
- /package/{type → build/types/type}/intrinsic/index.d.ts +0 -0
- /package/{type → build/types/type}/intrinsic/intrinsic.d.ts +0 -0
- /package/{type → build/types/type}/iterator/index.d.ts +0 -0
- /package/{type → build/types/type}/iterator/iterator.d.ts +0 -0
- /package/{type → build/types/type}/keyof/index.d.ts +0 -0
- /package/{type → build/types/type}/keyof/keyof-string.d.ts +0 -0
- /package/{type → build/types/type}/keyof/keyof-type.d.ts +0 -0
- /package/{type → build/types/type}/keyof/keyof.d.ts +0 -0
- /package/{type → build/types/type}/literal/index.d.ts +0 -0
- /package/{type → build/types/type}/literal/literal.d.ts +0 -0
- /package/{type → build/types/type}/mapped/index.d.ts +0 -0
- /package/{type → build/types/type}/mapped/mapped.d.ts +0 -0
- /package/{type → build/types/type}/modifiers/index.d.ts +0 -0
- /package/{type → build/types/type}/modifiers/modifiers.d.ts +0 -0
- /package/{type → build/types/type}/never/index.d.ts +0 -0
- /package/{type → build/types/type}/never/never.d.ts +0 -0
- /package/{type → build/types/type}/not/index.d.ts +0 -0
- /package/{type → build/types/type}/not/not.d.ts +0 -0
- /package/{type → build/types/type}/null/index.d.ts +0 -0
- /package/{type → build/types/type}/null/null.d.ts +0 -0
- /package/{type → build/types/type}/number/index.d.ts +0 -0
- /package/{type → build/types/type}/number/number.d.ts +0 -0
- /package/{type → build/types/type}/object/index.d.ts +0 -0
- /package/{type → build/types/type}/object/object.d.ts +0 -0
- /package/{type → build/types/type}/omit/index.d.ts +0 -0
- /package/{type → build/types/type}/omit/omit.d.ts +0 -0
- /package/{type → build/types/type}/operators/index.d.ts +0 -0
- /package/{type → build/types/type}/operators/operators.d.ts +0 -0
- /package/{type → build/types/type}/optional/index.d.ts +0 -0
- /package/{type → build/types/type}/optional/optional.d.ts +0 -0
- /package/{type → build/types/type}/parameters/index.d.ts +0 -0
- /package/{type → build/types/type}/parameters/parameters.d.ts +0 -0
- /package/{type → build/types/type}/partial/index.d.ts +0 -0
- /package/{type → build/types/type}/partial/partial.d.ts +0 -0
- /package/{type → build/types/type}/patterns/index.d.ts +0 -0
- /package/{type → build/types/type}/patterns/patterns.d.ts +0 -0
- /package/{type → build/types/type}/pick/index.d.ts +0 -0
- /package/{type → build/types/type}/pick/pick.d.ts +0 -0
- /package/{type → build/types/type}/promise/index.d.ts +0 -0
- /package/{type → build/types/type}/promise/promise.d.ts +0 -0
- /package/{type → build/types/type}/readonly/index.d.ts +0 -0
- /package/{type → build/types/type}/readonly/readonly.d.ts +0 -0
- /package/{type → build/types/type}/readonly-optional/index.d.ts +0 -0
- /package/{type → build/types/type}/readonly-optional/readonly-optional.d.ts +0 -0
- /package/{type → build/types/type}/record/index.d.ts +0 -0
- /package/{type → build/types/type}/record/record.d.ts +0 -0
- /package/{type → build/types/type}/recursive/index.d.ts +0 -0
- /package/{type → build/types/type}/recursive/recursive.d.ts +0 -0
- /package/{type → build/types/type}/ref/index.d.ts +0 -0
- /package/{type → build/types/type}/ref/ref.d.ts +0 -0
- /package/{type → build/types/type}/regexp/index.d.ts +0 -0
- /package/{type → build/types/type}/regexp/regexp.d.ts +0 -0
- /package/{type → build/types/type}/registry/format.d.ts +0 -0
- /package/{type → build/types/type}/registry/index.d.ts +0 -0
- /package/{type → build/types/type}/registry/type.d.ts +0 -0
- /package/{type → build/types/type}/required/index.d.ts +0 -0
- /package/{type → build/types/type}/required/required.d.ts +0 -0
- /package/{type → build/types/type}/rest/index.d.ts +0 -0
- /package/{type → build/types/type}/rest/rest.d.ts +0 -0
- /package/{type → build/types/type}/return-type/index.d.ts +0 -0
- /package/{type → build/types/type}/return-type/return-type.d.ts +0 -0
- /package/{type → build/types/type}/schema/anyschema.d.ts +0 -0
- /package/{type → build/types/type}/schema/index.d.ts +0 -0
- /package/{type → build/types/type}/schema/schema.d.ts +0 -0
- /package/{type → build/types/type}/static/index.d.ts +0 -0
- /package/{type → build/types/type}/static/static.d.ts +0 -0
- /package/{type → build/types/type}/strict/index.d.ts +0 -0
- /package/{type → build/types/type}/strict/strict.d.ts +0 -0
- /package/{type → build/types/type}/string/index.d.ts +0 -0
- /package/{type → build/types/type}/string/string.d.ts +0 -0
- /package/{type → build/types/type}/symbol/index.d.ts +0 -0
- /package/{type → build/types/type}/symbol/symbol.d.ts +0 -0
- /package/{type → build/types/type}/symbols/index.d.ts +0 -0
- /package/{type → build/types/type}/symbols/symbols.d.ts +0 -0
- /package/{type → build/types/type}/template-literal/finite.d.ts +0 -0
- /package/{type → build/types/type}/template-literal/generate.d.ts +0 -0
- /package/{type → build/types/type}/template-literal/index.d.ts +0 -0
- /package/{type → build/types/type}/template-literal/parser.d.ts +0 -0
- /package/{type → build/types/type}/template-literal/pattern.d.ts +0 -0
- /package/{type → build/types/type}/template-literal/syntax.d.ts +0 -0
- /package/{type → build/types/type}/template-literal/template-literal.d.ts +0 -0
- /package/{type → build/types/type}/template-literal/union.d.ts +0 -0
- /package/{type → build/types/type}/transform/index.d.ts +0 -0
- /package/{type → build/types/type}/transform/transform.d.ts +0 -0
- /package/{type → build/types/type}/tuple/index.d.ts +0 -0
- /package/{type → build/types/type}/tuple/tuple.d.ts +0 -0
- /package/{type → build/types/type}/type/index.d.ts +0 -0
- /package/{type → build/types/type}/type/javascript.d.ts +0 -0
- /package/{type → build/types/type}/type/json.d.ts +0 -0
- /package/{type → build/types/type}/type/type.d.ts +0 -0
- /package/{type → build/types/type}/uint8array/index.d.ts +0 -0
- /package/{type → build/types/type}/uint8array/uint8array.d.ts +0 -0
- /package/{type → build/types/type}/undefined/index.d.ts +0 -0
- /package/{type → build/types/type}/undefined/undefined.d.ts +0 -0
- /package/{type → build/types/type}/union/index.d.ts +0 -0
- /package/{type → build/types/type}/union/union.d.ts +0 -0
- /package/{type → build/types/type}/unknown/index.d.ts +0 -0
- /package/{type → build/types/type}/unknown/unknown.d.ts +0 -0
- /package/{type → build/types/type}/unsafe/index.d.ts +0 -0
- /package/{type → build/types/type}/unsafe/unsafe.d.ts +0 -0
- /package/{type → build/types/type}/void/index.d.ts +0 -0
- /package/{type → build/types/type}/void/void.d.ts +0 -0
- /package/{value → build/types/value}/cast/cast.d.ts +0 -0
- /package/{value → build/types/value}/cast/index.d.ts +0 -0
- /package/{value → build/types/value}/check/check.d.ts +0 -0
- /package/{value → build/types/value}/check/index.d.ts +0 -0
- /package/{value → build/types/value}/clean/clean.d.ts +0 -0
- /package/{value → build/types/value}/clean/index.d.ts +0 -0
- /package/{value → build/types/value}/clone/clone.d.ts +0 -0
- /package/{value → build/types/value}/clone/index.d.ts +0 -0
- /package/{value → build/types/value}/convert/convert.d.ts +0 -0
- /package/{value → build/types/value}/convert/index.d.ts +0 -0
- /package/{value → build/types/value}/create/create.d.ts +0 -0
- /package/{value → build/types/value}/create/index.d.ts +0 -0
- /package/{value → build/types/value}/default/default.d.ts +0 -0
- /package/{value → build/types/value}/default/index.d.ts +0 -0
- /package/{value → build/types/value}/delta/delta.d.ts +0 -0
- /package/{value → build/types/value}/delta/index.d.ts +0 -0
- /package/{value → build/types/value}/deref/deref.d.ts +0 -0
- /package/{value → build/types/value}/deref/index.d.ts +0 -0
- /package/{value → build/types/value}/equal/equal.d.ts +0 -0
- /package/{value → build/types/value}/equal/index.d.ts +0 -0
- /package/{value → build/types/value}/guard/guard.d.ts +0 -0
- /package/{value → build/types/value}/guard/index.d.ts +0 -0
- /package/{value → build/types/value}/hash/hash.d.ts +0 -0
- /package/{value → build/types/value}/hash/index.d.ts +0 -0
- /package/{value → build/types/value}/index.d.ts +0 -0
- /package/{value → build/types/value}/mutate/index.d.ts +0 -0
- /package/{value → build/types/value}/mutate/mutate.d.ts +0 -0
- /package/{value → build/types/value}/pointer/index.d.ts +0 -0
- /package/{value → build/types/value}/pointer/pointer.d.ts +0 -0
- /package/{value → build/types/value}/transform/decode.d.ts +0 -0
- /package/{value → build/types/value}/transform/encode.d.ts +0 -0
- /package/{value → build/types/value}/transform/has.d.ts +0 -0
- /package/{value → build/types/value}/transform/index.d.ts +0 -0
- /package/{value → build/types/value}/value/index.d.ts +0 -0
- /package/{value → build/types/value}/value/value.d.ts +0 -0
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
import { IsArray, IsUint8Array, IsDate, IsPromise, IsFunction, IsAsyncIterator, IsIterator, IsBoolean, IsNumber, IsBigInt, IsString, IsSymbol, IsInteger, IsNull, IsUndefined } from '../guard/index.mjs';
|
|
2
|
+
import { TypeSystemPolicy } from '../../system/index.mjs';
|
|
3
|
+
import { Deref } from '../deref/index.mjs';
|
|
4
|
+
import { Hash } from '../hash/index.mjs';
|
|
5
|
+
import { Kind } from '../../type/symbols/index.mjs';
|
|
6
|
+
import { KeyOfStringResolvePattern } from '../../type/keyof/index.mjs';
|
|
7
|
+
import { ExtendsUndefinedCheck } from '../../type/extends/index.mjs';
|
|
8
|
+
import { TSchema as IsSchemaType } from '../../type/guard/type.mjs';
|
|
9
|
+
import { TypeRegistry, FormatRegistry } from '../../type/registry/index.mjs';
|
|
10
|
+
import { Never } from '../../type/never/index.mjs';
|
|
11
|
+
export class ValueCheckUnknownTypeError extends Error {
|
|
12
|
+
schema;
|
|
13
|
+
constructor(schema) {
|
|
14
|
+
super(`Unknown type`);
|
|
15
|
+
this.schema = schema;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function IsAnyOrUnknown(schema) {
|
|
19
|
+
return schema[Kind] === 'Any' || schema[Kind] === 'Unknown';
|
|
20
|
+
}
|
|
21
|
+
function IsDefined(value) {
|
|
22
|
+
return value !== undefined;
|
|
23
|
+
}
|
|
24
|
+
function TAny(schema, references, value) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
function TArray(schema, references, value) {
|
|
28
|
+
if (!IsArray(value))
|
|
29
|
+
return false;
|
|
30
|
+
if (IsDefined(schema.minItems) && !(value.length >= schema.minItems)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
if (IsDefined(schema.maxItems) && !(value.length <= schema.maxItems)) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (!value.every((value) => Visit(schema.items, references, value))) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
if (schema.uniqueItems === true && !((function () { const set = new Set(); for (const element of value) {
|
|
40
|
+
const hashed = Hash(element);
|
|
41
|
+
if (set.has(hashed)) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
set.add(hashed);
|
|
46
|
+
}
|
|
47
|
+
} return true; })())) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
if (!(IsDefined(schema.contains) || IsNumber(schema.minContains) || IsNumber(schema.maxContains))) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
const containsSchema = IsDefined(schema.contains) ? schema.contains : Never();
|
|
54
|
+
const containsCount = value.reduce((acc, value) => (Visit(containsSchema, references, value) ? acc + 1 : acc), 0);
|
|
55
|
+
if (containsCount === 0) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
if (IsNumber(schema.minContains) && containsCount < schema.minContains) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
if (IsNumber(schema.maxContains) && containsCount > schema.maxContains) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
function TAsyncIterator(schema, references, value) {
|
|
67
|
+
return IsAsyncIterator(value);
|
|
68
|
+
}
|
|
69
|
+
function TBigInt(schema, references, value) {
|
|
70
|
+
if (!IsBigInt(value))
|
|
71
|
+
return false;
|
|
72
|
+
if (IsDefined(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
if (IsDefined(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
if (IsDefined(schema.maximum) && !(value <= schema.maximum)) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
if (IsDefined(schema.minimum) && !(value >= schema.minimum)) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
if (IsDefined(schema.multipleOf) && !(value % schema.multipleOf === BigInt(0))) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
function TBoolean(schema, references, value) {
|
|
90
|
+
return IsBoolean(value);
|
|
91
|
+
}
|
|
92
|
+
function TConstructor(schema, references, value) {
|
|
93
|
+
return Visit(schema.returns, references, value.prototype);
|
|
94
|
+
}
|
|
95
|
+
function TDate(schema, references, value) {
|
|
96
|
+
if (!IsDate(value))
|
|
97
|
+
return false;
|
|
98
|
+
if (IsDefined(schema.exclusiveMaximumTimestamp) && !(value.getTime() < schema.exclusiveMaximumTimestamp)) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
if (IsDefined(schema.exclusiveMinimumTimestamp) && !(value.getTime() > schema.exclusiveMinimumTimestamp)) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
if (IsDefined(schema.maximumTimestamp) && !(value.getTime() <= schema.maximumTimestamp)) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
if (IsDefined(schema.minimumTimestamp) && !(value.getTime() >= schema.minimumTimestamp)) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
if (IsDefined(schema.multipleOfTimestamp) && !(value.getTime() % schema.multipleOfTimestamp === 0)) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
function TFunction(schema, references, value) {
|
|
116
|
+
return IsFunction(value);
|
|
117
|
+
}
|
|
118
|
+
function TInteger(schema, references, value) {
|
|
119
|
+
if (!IsInteger(value)) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
if (IsDefined(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
if (IsDefined(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
if (IsDefined(schema.maximum) && !(value <= schema.maximum)) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
if (IsDefined(schema.minimum) && !(value >= schema.minimum)) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
if (IsDefined(schema.multipleOf) && !(value % schema.multipleOf === 0)) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
function TIntersect(schema, references, value) {
|
|
140
|
+
const check1 = schema.allOf.every((schema) => Visit(schema, references, value));
|
|
141
|
+
if (schema.unevaluatedProperties === false) {
|
|
142
|
+
const keyPattern = new RegExp(KeyOfStringResolvePattern(schema));
|
|
143
|
+
const check2 = Object.getOwnPropertyNames(value).every((key) => keyPattern.test(key));
|
|
144
|
+
return check1 && check2;
|
|
145
|
+
}
|
|
146
|
+
else if (IsSchemaType(schema.unevaluatedProperties)) {
|
|
147
|
+
const keyCheck = new RegExp(KeyOfStringResolvePattern(schema));
|
|
148
|
+
const check2 = Object.getOwnPropertyNames(value).every((key) => keyCheck.test(key) || Visit(schema.unevaluatedProperties, references, value[key]));
|
|
149
|
+
return check1 && check2;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
return check1;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function TIterator(schema, references, value) {
|
|
156
|
+
return IsIterator(value);
|
|
157
|
+
}
|
|
158
|
+
function TLiteral(schema, references, value) {
|
|
159
|
+
return value === schema.const;
|
|
160
|
+
}
|
|
161
|
+
function TNever(schema, references, value) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
function TNot(schema, references, value) {
|
|
165
|
+
return !Visit(schema.not, references, value);
|
|
166
|
+
}
|
|
167
|
+
function TNull(schema, references, value) {
|
|
168
|
+
return IsNull(value);
|
|
169
|
+
}
|
|
170
|
+
function TNumber(schema, references, value) {
|
|
171
|
+
if (!TypeSystemPolicy.IsNumberLike(value))
|
|
172
|
+
return false;
|
|
173
|
+
if (IsDefined(schema.exclusiveMaximum) && !(value < schema.exclusiveMaximum)) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
if (IsDefined(schema.exclusiveMinimum) && !(value > schema.exclusiveMinimum)) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
if (IsDefined(schema.minimum) && !(value >= schema.minimum)) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
if (IsDefined(schema.maximum) && !(value <= schema.maximum)) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
if (IsDefined(schema.multipleOf) && !(value % schema.multipleOf === 0)) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
function TObject(schema, references, value) {
|
|
191
|
+
if (!TypeSystemPolicy.IsObjectLike(value))
|
|
192
|
+
return false;
|
|
193
|
+
if (IsDefined(schema.minProperties) && !(Object.getOwnPropertyNames(value).length >= schema.minProperties)) {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
if (IsDefined(schema.maxProperties) && !(Object.getOwnPropertyNames(value).length <= schema.maxProperties)) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
const knownKeys = Object.getOwnPropertyNames(schema.properties);
|
|
200
|
+
for (const knownKey of knownKeys) {
|
|
201
|
+
const property = schema.properties[knownKey];
|
|
202
|
+
if (schema.required && schema.required.includes(knownKey)) {
|
|
203
|
+
if (!Visit(property, references, value[knownKey])) {
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
if ((ExtendsUndefinedCheck(property) || IsAnyOrUnknown(property)) && !(knownKey in value)) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
if (TypeSystemPolicy.IsExactOptionalProperty(value, knownKey) && !Visit(property, references, value[knownKey])) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (schema.additionalProperties === false) {
|
|
217
|
+
const valueKeys = Object.getOwnPropertyNames(value);
|
|
218
|
+
if (schema.required && schema.required.length === knownKeys.length && valueKeys.length === knownKeys.length) {
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
return valueKeys.every((valueKey) => knownKeys.includes(valueKey));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
else if (typeof schema.additionalProperties === 'object') {
|
|
226
|
+
const valueKeys = Object.getOwnPropertyNames(value);
|
|
227
|
+
return valueKeys.every((key) => knownKeys.includes(key) || Visit(schema.additionalProperties, references, value[key]));
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
function TPromise(schema, references, value) {
|
|
234
|
+
return IsPromise(value);
|
|
235
|
+
}
|
|
236
|
+
function TRecord(schema, references, value) {
|
|
237
|
+
if (!TypeSystemPolicy.IsRecordLike(value)) {
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
if (IsDefined(schema.minProperties) && !(Object.getOwnPropertyNames(value).length >= schema.minProperties)) {
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
if (IsDefined(schema.maxProperties) && !(Object.getOwnPropertyNames(value).length <= schema.maxProperties)) {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
const [patternKey, patternSchema] = Object.entries(schema.patternProperties)[0];
|
|
247
|
+
const regex = new RegExp(patternKey);
|
|
248
|
+
const check1 = Object.entries(value).every(([key, value]) => {
|
|
249
|
+
return (regex.test(key)) ? Visit(patternSchema, references, value) : true;
|
|
250
|
+
});
|
|
251
|
+
const check2 = typeof schema.additionalProperties === 'object' ? Object.entries(value).every(([key, value]) => {
|
|
252
|
+
return (!regex.test(key)) ? Visit(schema.additionalProperties, references, value) : true;
|
|
253
|
+
}) : true;
|
|
254
|
+
const check3 = schema.additionalProperties === false
|
|
255
|
+
? Object.getOwnPropertyNames(value).every((key) => {
|
|
256
|
+
return regex.test(key);
|
|
257
|
+
})
|
|
258
|
+
: true;
|
|
259
|
+
return check1 && check2 && check3;
|
|
260
|
+
}
|
|
261
|
+
function TRef(schema, references, value) {
|
|
262
|
+
return Visit(Deref(schema, references), references, value);
|
|
263
|
+
}
|
|
264
|
+
function TString(schema, references, value) {
|
|
265
|
+
if (!IsString(value)) {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
if (IsDefined(schema.minLength)) {
|
|
269
|
+
if (!(value.length >= schema.minLength))
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
if (IsDefined(schema.maxLength)) {
|
|
273
|
+
if (!(value.length <= schema.maxLength))
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
if (IsDefined(schema.pattern)) {
|
|
277
|
+
const regex = new RegExp(schema.pattern);
|
|
278
|
+
if (!regex.test(value))
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
if (IsDefined(schema.format)) {
|
|
282
|
+
if (!FormatRegistry.Has(schema.format))
|
|
283
|
+
return false;
|
|
284
|
+
const func = FormatRegistry.Get(schema.format);
|
|
285
|
+
return func(value);
|
|
286
|
+
}
|
|
287
|
+
return true;
|
|
288
|
+
}
|
|
289
|
+
function TSymbol(schema, references, value) {
|
|
290
|
+
return IsSymbol(value);
|
|
291
|
+
}
|
|
292
|
+
function TTemplateLiteral(schema, references, value) {
|
|
293
|
+
return IsString(value) && new RegExp(schema.pattern).test(value);
|
|
294
|
+
}
|
|
295
|
+
function TThis(schema, references, value) {
|
|
296
|
+
return Visit(Deref(schema, references), references, value);
|
|
297
|
+
}
|
|
298
|
+
function TTuple(schema, references, value) {
|
|
299
|
+
if (!IsArray(value)) {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
if (schema.items === undefined && !(value.length === 0)) {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
if (!(value.length === schema.maxItems)) {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
if (!schema.items) {
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
for (let i = 0; i < schema.items.length; i++) {
|
|
312
|
+
if (!Visit(schema.items[i], references, value[i]))
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
return true;
|
|
316
|
+
}
|
|
317
|
+
function TUndefined(schema, references, value) {
|
|
318
|
+
return IsUndefined(value);
|
|
319
|
+
}
|
|
320
|
+
function TUnion(schema, references, value) {
|
|
321
|
+
return schema.anyOf.some((inner) => Visit(inner, references, value));
|
|
322
|
+
}
|
|
323
|
+
function TUint8Array(schema, references, value) {
|
|
324
|
+
if (!IsUint8Array(value)) {
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
if (IsDefined(schema.maxByteLength) && !(value.length <= schema.maxByteLength)) {
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
330
|
+
if (IsDefined(schema.minByteLength) && !(value.length >= schema.minByteLength)) {
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
335
|
+
function TUnknown(schema, references, value) {
|
|
336
|
+
return true;
|
|
337
|
+
}
|
|
338
|
+
function TVoid(schema, references, value) {
|
|
339
|
+
return TypeSystemPolicy.IsVoidLike(value);
|
|
340
|
+
}
|
|
341
|
+
function TKind(schema, references, value) {
|
|
342
|
+
if (!TypeRegistry.Has(schema[Kind]))
|
|
343
|
+
return false;
|
|
344
|
+
const func = TypeRegistry.Get(schema[Kind]);
|
|
345
|
+
return func(schema, value);
|
|
346
|
+
}
|
|
347
|
+
function Visit(schema, references, value) {
|
|
348
|
+
const references_ = IsDefined(schema.$id) ? [...references, schema] : references;
|
|
349
|
+
const schema_ = schema;
|
|
350
|
+
switch (schema_[Kind]) {
|
|
351
|
+
case 'Any':
|
|
352
|
+
return TAny(schema_, references_, value);
|
|
353
|
+
case 'Array':
|
|
354
|
+
return TArray(schema_, references_, value);
|
|
355
|
+
case 'AsyncIterator':
|
|
356
|
+
return TAsyncIterator(schema_, references_, value);
|
|
357
|
+
case 'BigInt':
|
|
358
|
+
return TBigInt(schema_, references_, value);
|
|
359
|
+
case 'Boolean':
|
|
360
|
+
return TBoolean(schema_, references_, value);
|
|
361
|
+
case 'Constructor':
|
|
362
|
+
return TConstructor(schema_, references_, value);
|
|
363
|
+
case 'Date':
|
|
364
|
+
return TDate(schema_, references_, value);
|
|
365
|
+
case 'Function':
|
|
366
|
+
return TFunction(schema_, references_, value);
|
|
367
|
+
case 'Integer':
|
|
368
|
+
return TInteger(schema_, references_, value);
|
|
369
|
+
case 'Intersect':
|
|
370
|
+
return TIntersect(schema_, references_, value);
|
|
371
|
+
case 'Iterator':
|
|
372
|
+
return TIterator(schema_, references_, value);
|
|
373
|
+
case 'Literal':
|
|
374
|
+
return TLiteral(schema_, references_, value);
|
|
375
|
+
case 'Never':
|
|
376
|
+
return TNever(schema_, references_, value);
|
|
377
|
+
case 'Not':
|
|
378
|
+
return TNot(schema_, references_, value);
|
|
379
|
+
case 'Null':
|
|
380
|
+
return TNull(schema_, references_, value);
|
|
381
|
+
case 'Number':
|
|
382
|
+
return TNumber(schema_, references_, value);
|
|
383
|
+
case 'Object':
|
|
384
|
+
return TObject(schema_, references_, value);
|
|
385
|
+
case 'Promise':
|
|
386
|
+
return TPromise(schema_, references_, value);
|
|
387
|
+
case 'Record':
|
|
388
|
+
return TRecord(schema_, references_, value);
|
|
389
|
+
case 'Ref':
|
|
390
|
+
return TRef(schema_, references_, value);
|
|
391
|
+
case 'String':
|
|
392
|
+
return TString(schema_, references_, value);
|
|
393
|
+
case 'Symbol':
|
|
394
|
+
return TSymbol(schema_, references_, value);
|
|
395
|
+
case 'TemplateLiteral':
|
|
396
|
+
return TTemplateLiteral(schema_, references_, value);
|
|
397
|
+
case 'This':
|
|
398
|
+
return TThis(schema_, references_, value);
|
|
399
|
+
case 'Tuple':
|
|
400
|
+
return TTuple(schema_, references_, value);
|
|
401
|
+
case 'Undefined':
|
|
402
|
+
return TUndefined(schema_, references_, value);
|
|
403
|
+
case 'Union':
|
|
404
|
+
return TUnion(schema_, references_, value);
|
|
405
|
+
case 'Uint8Array':
|
|
406
|
+
return TUint8Array(schema_, references_, value);
|
|
407
|
+
case 'Unknown':
|
|
408
|
+
return TUnknown(schema_, references_, value);
|
|
409
|
+
case 'Void':
|
|
410
|
+
return TVoid(schema_, references_, value);
|
|
411
|
+
default:
|
|
412
|
+
if (!TypeRegistry.Has(schema_[Kind]))
|
|
413
|
+
throw new ValueCheckUnknownTypeError(schema_);
|
|
414
|
+
return TKind(schema_, references_, value);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
export function Check(...args) {
|
|
418
|
+
return args.length === 3 ? Visit(args[0], args[1], args[2]) : Visit(args[0], [], args[1]);
|
|
419
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './check.mjs';
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { IsString, IsObject, IsArray, IsUndefined } from '../guard/index.mjs';
|
|
2
|
+
import { TSchema as IsSchemaType } from '../../type/guard/type.mjs';
|
|
3
|
+
import { KeyOfStringResolve } from '../../type/keyof/keyof-string.mjs';
|
|
4
|
+
import { Check } from '../check/index.mjs';
|
|
5
|
+
import { Clone } from '../clone/index.mjs';
|
|
6
|
+
import { Deref } from '../deref/index.mjs';
|
|
7
|
+
import { Kind } from '../../type/symbols/index.mjs';
|
|
8
|
+
function IsSchema(schema) {
|
|
9
|
+
return IsSchemaType(schema);
|
|
10
|
+
}
|
|
11
|
+
function IsCheckable(schema) {
|
|
12
|
+
return IsSchemaType(schema) && schema[Kind] !== 'Unsafe';
|
|
13
|
+
}
|
|
14
|
+
function TArray(schema, references, value) {
|
|
15
|
+
if (!IsArray(value))
|
|
16
|
+
return value;
|
|
17
|
+
return value.map((value) => Visit(schema.items, references, value));
|
|
18
|
+
}
|
|
19
|
+
function TIntersect(schema, references, value) {
|
|
20
|
+
const unevaluatedProperties = schema.unevaluatedProperties;
|
|
21
|
+
const intersections = schema.allOf.map((schema) => Visit(schema, references, Clone(value)));
|
|
22
|
+
const composite = intersections.reduce((acc, value) => (IsObject(value) ? { ...acc, ...value } : value), {});
|
|
23
|
+
if (!IsObject(value) || !IsObject(composite) || !IsSchema(unevaluatedProperties))
|
|
24
|
+
return composite;
|
|
25
|
+
const knownkeys = KeyOfStringResolve(schema);
|
|
26
|
+
for (const key of Object.getOwnPropertyNames(value)) {
|
|
27
|
+
if (knownkeys.includes(key))
|
|
28
|
+
continue;
|
|
29
|
+
if (Check(unevaluatedProperties, references, value[key])) {
|
|
30
|
+
composite[key] = Visit(unevaluatedProperties, references, value[key]);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return composite;
|
|
34
|
+
}
|
|
35
|
+
function TObject(schema, references, value) {
|
|
36
|
+
if (!IsObject(value) || IsArray(value))
|
|
37
|
+
return value;
|
|
38
|
+
const additionalProperties = schema.additionalProperties;
|
|
39
|
+
for (const key of Object.getOwnPropertyNames(value)) {
|
|
40
|
+
if (key in schema.properties) {
|
|
41
|
+
value[key] = Visit(schema.properties[key], references, value[key]);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (IsSchema(additionalProperties) && Check(additionalProperties, references, value[key])) {
|
|
45
|
+
value[key] = Visit(additionalProperties, references, value[key]);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
delete value[key];
|
|
49
|
+
}
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
function TRecord(schema, references, value) {
|
|
53
|
+
if (!IsObject(value))
|
|
54
|
+
return value;
|
|
55
|
+
const additionalProperties = schema.additionalProperties;
|
|
56
|
+
const propertyKeys = Object.keys(value);
|
|
57
|
+
const [propertyKey, propertySchema] = Object.entries(schema.patternProperties)[0];
|
|
58
|
+
const propertyKeyTest = new RegExp(propertyKey);
|
|
59
|
+
for (const key of propertyKeys) {
|
|
60
|
+
if (propertyKeyTest.test(key)) {
|
|
61
|
+
value[key] = Visit(propertySchema, references, value[key]);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (IsSchema(additionalProperties) && Check(additionalProperties, references, value[key])) {
|
|
65
|
+
value[key] = Visit(additionalProperties, references, value[key]);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
delete value[key];
|
|
69
|
+
}
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
function TRef(schema, references, value) {
|
|
73
|
+
return Visit(Deref(schema, references), references, value);
|
|
74
|
+
}
|
|
75
|
+
function TThis(schema, references, value) {
|
|
76
|
+
return Visit(Deref(schema, references), references, value);
|
|
77
|
+
}
|
|
78
|
+
function TTuple(schema, references, value) {
|
|
79
|
+
if (!IsArray(value))
|
|
80
|
+
return value;
|
|
81
|
+
if (IsUndefined(schema.items))
|
|
82
|
+
return [];
|
|
83
|
+
const length = Math.min(value.length, schema.items.length);
|
|
84
|
+
for (let i = 0; i < length; i++) {
|
|
85
|
+
value[i] = Visit(schema.items[i], references, value[i]);
|
|
86
|
+
}
|
|
87
|
+
return value.length > length
|
|
88
|
+
? value.slice(0, length)
|
|
89
|
+
: value;
|
|
90
|
+
}
|
|
91
|
+
function TUnion(schema, references, value) {
|
|
92
|
+
for (const inner of schema.anyOf) {
|
|
93
|
+
if (IsCheckable(inner) && Check(inner, value)) {
|
|
94
|
+
return Visit(inner, references, value);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return value;
|
|
98
|
+
}
|
|
99
|
+
function Visit(schema, references, value) {
|
|
100
|
+
const references_ = IsString(schema.$id) ? [...references, schema] : references;
|
|
101
|
+
const schema_ = schema;
|
|
102
|
+
switch (schema_[Kind]) {
|
|
103
|
+
case 'Array':
|
|
104
|
+
return TArray(schema_, references_, value);
|
|
105
|
+
case 'Intersect':
|
|
106
|
+
return TIntersect(schema_, references_, value);
|
|
107
|
+
case 'Object':
|
|
108
|
+
return TObject(schema_, references_, value);
|
|
109
|
+
case 'Record':
|
|
110
|
+
return TRecord(schema_, references_, value);
|
|
111
|
+
case 'Ref':
|
|
112
|
+
return TRef(schema_, references_, value);
|
|
113
|
+
case 'This':
|
|
114
|
+
return TThis(schema_, references_, value);
|
|
115
|
+
case 'Tuple':
|
|
116
|
+
return TTuple(schema_, references_, value);
|
|
117
|
+
case 'Union':
|
|
118
|
+
return TUnion(schema_, references_, value);
|
|
119
|
+
default:
|
|
120
|
+
return value;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export function Clean(...args) {
|
|
124
|
+
return args.length === 3 ? Visit(args[0], args[1], args[2]) : Visit(args[0], [], args[1]);
|
|
125
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './clean.mjs';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { IsArray, IsDate, IsPlainObject, IsTypedArray, IsValueType } from '../guard/index.mjs';
|
|
2
|
+
function ObjectType(value) {
|
|
3
|
+
const keys = [...Object.getOwnPropertyNames(value), ...Object.getOwnPropertySymbols(value)];
|
|
4
|
+
return keys.reduce((acc, key) => ({ ...acc, [key]: Clone(value[key]) }), {});
|
|
5
|
+
}
|
|
6
|
+
function ArrayType(value) {
|
|
7
|
+
return value.map((element) => Clone(element));
|
|
8
|
+
}
|
|
9
|
+
function TypedArrayType(value) {
|
|
10
|
+
return value.slice();
|
|
11
|
+
}
|
|
12
|
+
function DateType(value) {
|
|
13
|
+
return new Date(value.toISOString());
|
|
14
|
+
}
|
|
15
|
+
function ValueType(value) {
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
export function Clone(value) {
|
|
19
|
+
if (IsArray(value))
|
|
20
|
+
return ArrayType(value);
|
|
21
|
+
if (IsDate(value))
|
|
22
|
+
return DateType(value);
|
|
23
|
+
if (IsPlainObject(value))
|
|
24
|
+
return ObjectType(value);
|
|
25
|
+
if (IsTypedArray(value))
|
|
26
|
+
return TypedArrayType(value);
|
|
27
|
+
if (IsValueType(value))
|
|
28
|
+
return ValueType(value);
|
|
29
|
+
throw new Error('ValueClone: Unable to clone value');
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './clone.mjs';
|