is-kit 1.11.2 → 1.11.3
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/dist/index.d.mts +13 -7
- package/dist/index.d.ts +13 -7
- package/dist/index.js +3 -1
- package/dist/index.mjs +3 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -39,6 +39,13 @@ type SchemaField = Predicate<unknown> | OptionalSchemaField<Predicate<unknown>>;
|
|
|
39
39
|
* Object schema consumed by `struct`.
|
|
40
40
|
*/
|
|
41
41
|
type Schema = Readonly<Record<string, SchemaField>>;
|
|
42
|
+
/**
|
|
43
|
+
* Configures object-key validation for `struct` and `typedStruct`.
|
|
44
|
+
*/
|
|
45
|
+
type StructOptions = Readonly<{
|
|
46
|
+
/** Rejects extra own enumerable string-key properties when enabled. */
|
|
47
|
+
exact?: boolean;
|
|
48
|
+
}>;
|
|
42
49
|
/**
|
|
43
50
|
* Object schema shape preserving concrete keys.
|
|
44
51
|
*/
|
|
@@ -686,20 +693,19 @@ declare function optionalKey<G extends Predicate<unknown>>(guard: G): OptionalSc
|
|
|
686
693
|
* properties not in `schema`.
|
|
687
694
|
* @returns Predicate that narrows to the inferred struct type.
|
|
688
695
|
*/
|
|
689
|
-
declare function struct<const S extends SchemaShape<S>>(schema: S, options?:
|
|
690
|
-
exact?: boolean;
|
|
691
|
-
}): Predicate<InferSchema<S>>;
|
|
696
|
+
declare function struct<const S extends SchemaShape<S>>(schema: S, options?: StructOptions): Predicate<InferSchema<S>>;
|
|
692
697
|
|
|
693
698
|
/**
|
|
694
699
|
* Creates a `struct` builder checked against an existing object type.
|
|
695
700
|
* Optional target keys must also be declared with `optionalKey` so type drift
|
|
696
701
|
* stays visible when the target type changes.
|
|
697
702
|
*
|
|
703
|
+
* Target-compatible field guards may narrow further than the target field type;
|
|
704
|
+
* the returned predicate preserves those narrower inferred types.
|
|
705
|
+
*
|
|
698
706
|
* @returns Builder that rejects missing, extra, or incompatible struct fields.
|
|
699
707
|
*/
|
|
700
|
-
declare function typedStruct<T extends object>(): <const S extends TypedStructShape<T>>(fields: TypedStructFields<T, S>, options?:
|
|
701
|
-
exact?: boolean;
|
|
702
|
-
}) => Predicate<InferSchema<TypedStructFields<T, S>>>;
|
|
708
|
+
declare function typedStruct<T extends object>(): <const S extends TypedStructShape<T>>(fields: TypedStructFields<T, S>, options?: StructOptions) => Predicate<InferSchema<TypedStructFields<T, S>>>;
|
|
703
709
|
|
|
704
710
|
/**
|
|
705
711
|
* Validates a fixed-length tuple by applying element-wise guards.
|
|
@@ -763,4 +769,4 @@ declare const everyOwnEnumerableEntry: (values: Record<string, unknown>, keyPred
|
|
|
763
769
|
*/
|
|
764
770
|
declare const toBooleanPredicates: <A>(predicates: readonly ((value: A) => boolean)[]) => ReadonlyArray<(value: A) => boolean>;
|
|
765
771
|
|
|
766
|
-
export { type ChainResult, type Guard, type GuardedOf, type GuardedWithin, type InferSchema, type NoExtraKeys, type OptionalObjectKeys, type OptionalSchemaField, type OutOfGuards, type ParseResult, type Predicate, type Primitive, type Refine, type RefineChain, type Refinement, type RequiredObjectKeys, type Schema, type SchemaField, type TypedStructFields, type TypedStructShape, and, andAll, arrayOf, assert, define, equals, equalsBy, equalsKey, everyArrayValue, everyMapEntry, everyOwnEnumerableEntry, everySetValue, everyTupleValue, guardIn, hasKey, hasKeys, isArray, isArrayBuffer, isAsyncIterable, isBigInt, isBlob, isBoolean, isDataView, isDate, isError, isFile, isFiniteNumber, isFunction, isInfiniteNumber, isInstanceOf, isInteger, isIterable, isMap, isNaN, isNegative, isNil, isNull, isNumber, isNumberPrimitive, isObject, isPlainObject, isPositive, isPrimitive, isPromiseLike, isRegExp, isSafeInteger, isSet, isString, isSymbol, isTypedArray, isURL, isUndefined, isWeakMap, isWeakSet, isZero, lazy, mapOf, narrowKeyTo, nonEmptyArrayOf, nonNull, not, nullable, nullish, oneOf, oneOfValues, optional, optionalKey, or, predicateToRefine, recordOf, required, safeJsonParse, safeParse, safeParseWith, setOf, struct, toBooleanPredicates, tupleOf, typedStruct };
|
|
772
|
+
export { type ChainResult, type Guard, type GuardedOf, type GuardedWithin, type InferSchema, type NoExtraKeys, type OptionalObjectKeys, type OptionalSchemaField, type OutOfGuards, type ParseResult, type Predicate, type Primitive, type Refine, type RefineChain, type Refinement, type RequiredObjectKeys, type Schema, type SchemaField, type StructOptions, type TypedStructFields, type TypedStructShape, and, andAll, arrayOf, assert, define, equals, equalsBy, equalsKey, everyArrayValue, everyMapEntry, everyOwnEnumerableEntry, everySetValue, everyTupleValue, guardIn, hasKey, hasKeys, isArray, isArrayBuffer, isAsyncIterable, isBigInt, isBlob, isBoolean, isDataView, isDate, isError, isFile, isFiniteNumber, isFunction, isInfiniteNumber, isInstanceOf, isInteger, isIterable, isMap, isNaN, isNegative, isNil, isNull, isNumber, isNumberPrimitive, isObject, isPlainObject, isPositive, isPrimitive, isPromiseLike, isRegExp, isSafeInteger, isSet, isString, isSymbol, isTypedArray, isURL, isUndefined, isWeakMap, isWeakSet, isZero, lazy, mapOf, narrowKeyTo, nonEmptyArrayOf, nonNull, not, nullable, nullish, oneOf, oneOfValues, optional, optionalKey, or, predicateToRefine, recordOf, required, safeJsonParse, safeParse, safeParseWith, setOf, struct, toBooleanPredicates, tupleOf, typedStruct };
|
package/dist/index.d.ts
CHANGED
|
@@ -39,6 +39,13 @@ type SchemaField = Predicate<unknown> | OptionalSchemaField<Predicate<unknown>>;
|
|
|
39
39
|
* Object schema consumed by `struct`.
|
|
40
40
|
*/
|
|
41
41
|
type Schema = Readonly<Record<string, SchemaField>>;
|
|
42
|
+
/**
|
|
43
|
+
* Configures object-key validation for `struct` and `typedStruct`.
|
|
44
|
+
*/
|
|
45
|
+
type StructOptions = Readonly<{
|
|
46
|
+
/** Rejects extra own enumerable string-key properties when enabled. */
|
|
47
|
+
exact?: boolean;
|
|
48
|
+
}>;
|
|
42
49
|
/**
|
|
43
50
|
* Object schema shape preserving concrete keys.
|
|
44
51
|
*/
|
|
@@ -686,20 +693,19 @@ declare function optionalKey<G extends Predicate<unknown>>(guard: G): OptionalSc
|
|
|
686
693
|
* properties not in `schema`.
|
|
687
694
|
* @returns Predicate that narrows to the inferred struct type.
|
|
688
695
|
*/
|
|
689
|
-
declare function struct<const S extends SchemaShape<S>>(schema: S, options?:
|
|
690
|
-
exact?: boolean;
|
|
691
|
-
}): Predicate<InferSchema<S>>;
|
|
696
|
+
declare function struct<const S extends SchemaShape<S>>(schema: S, options?: StructOptions): Predicate<InferSchema<S>>;
|
|
692
697
|
|
|
693
698
|
/**
|
|
694
699
|
* Creates a `struct` builder checked against an existing object type.
|
|
695
700
|
* Optional target keys must also be declared with `optionalKey` so type drift
|
|
696
701
|
* stays visible when the target type changes.
|
|
697
702
|
*
|
|
703
|
+
* Target-compatible field guards may narrow further than the target field type;
|
|
704
|
+
* the returned predicate preserves those narrower inferred types.
|
|
705
|
+
*
|
|
698
706
|
* @returns Builder that rejects missing, extra, or incompatible struct fields.
|
|
699
707
|
*/
|
|
700
|
-
declare function typedStruct<T extends object>(): <const S extends TypedStructShape<T>>(fields: TypedStructFields<T, S>, options?:
|
|
701
|
-
exact?: boolean;
|
|
702
|
-
}) => Predicate<InferSchema<TypedStructFields<T, S>>>;
|
|
708
|
+
declare function typedStruct<T extends object>(): <const S extends TypedStructShape<T>>(fields: TypedStructFields<T, S>, options?: StructOptions) => Predicate<InferSchema<TypedStructFields<T, S>>>;
|
|
703
709
|
|
|
704
710
|
/**
|
|
705
711
|
* Validates a fixed-length tuple by applying element-wise guards.
|
|
@@ -763,4 +769,4 @@ declare const everyOwnEnumerableEntry: (values: Record<string, unknown>, keyPred
|
|
|
763
769
|
*/
|
|
764
770
|
declare const toBooleanPredicates: <A>(predicates: readonly ((value: A) => boolean)[]) => ReadonlyArray<(value: A) => boolean>;
|
|
765
771
|
|
|
766
|
-
export { type ChainResult, type Guard, type GuardedOf, type GuardedWithin, type InferSchema, type NoExtraKeys, type OptionalObjectKeys, type OptionalSchemaField, type OutOfGuards, type ParseResult, type Predicate, type Primitive, type Refine, type RefineChain, type Refinement, type RequiredObjectKeys, type Schema, type SchemaField, type TypedStructFields, type TypedStructShape, and, andAll, arrayOf, assert, define, equals, equalsBy, equalsKey, everyArrayValue, everyMapEntry, everyOwnEnumerableEntry, everySetValue, everyTupleValue, guardIn, hasKey, hasKeys, isArray, isArrayBuffer, isAsyncIterable, isBigInt, isBlob, isBoolean, isDataView, isDate, isError, isFile, isFiniteNumber, isFunction, isInfiniteNumber, isInstanceOf, isInteger, isIterable, isMap, isNaN, isNegative, isNil, isNull, isNumber, isNumberPrimitive, isObject, isPlainObject, isPositive, isPrimitive, isPromiseLike, isRegExp, isSafeInteger, isSet, isString, isSymbol, isTypedArray, isURL, isUndefined, isWeakMap, isWeakSet, isZero, lazy, mapOf, narrowKeyTo, nonEmptyArrayOf, nonNull, not, nullable, nullish, oneOf, oneOfValues, optional, optionalKey, or, predicateToRefine, recordOf, required, safeJsonParse, safeParse, safeParseWith, setOf, struct, toBooleanPredicates, tupleOf, typedStruct };
|
|
772
|
+
export { type ChainResult, type Guard, type GuardedOf, type GuardedWithin, type InferSchema, type NoExtraKeys, type OptionalObjectKeys, type OptionalSchemaField, type OutOfGuards, type ParseResult, type Predicate, type Primitive, type Refine, type RefineChain, type Refinement, type RequiredObjectKeys, type Schema, type SchemaField, type StructOptions, type TypedStructFields, type TypedStructShape, and, andAll, arrayOf, assert, define, equals, equalsBy, equalsKey, everyArrayValue, everyMapEntry, everyOwnEnumerableEntry, everySetValue, everyTupleValue, guardIn, hasKey, hasKeys, isArray, isArrayBuffer, isAsyncIterable, isBigInt, isBlob, isBoolean, isDataView, isDate, isError, isFile, isFiniteNumber, isFunction, isInfiniteNumber, isInstanceOf, isInteger, isIterable, isMap, isNaN, isNegative, isNil, isNull, isNumber, isNumberPrimitive, isObject, isPlainObject, isPositive, isPrimitive, isPromiseLike, isRegExp, isSafeInteger, isSet, isString, isSymbol, isTypedArray, isURL, isUndefined, isWeakMap, isWeakSet, isZero, lazy, mapOf, narrowKeyTo, nonEmptyArrayOf, nonNull, not, nullable, nullish, oneOf, oneOfValues, optional, optionalKey, or, predicateToRefine, recordOf, required, safeJsonParse, safeParse, safeParseWith, setOf, struct, toBooleanPredicates, tupleOf, typedStruct };
|
package/dist/index.js
CHANGED
|
@@ -473,7 +473,9 @@ var isOptionalSchemaField = define(
|
|
|
473
473
|
var hasRequiredKeys = (obj, entries) => (
|
|
474
474
|
// WHY: Required fields must be own properties; inherited values should not
|
|
475
475
|
// satisfy a schema because `struct` models object payload shape, not prototype chains.
|
|
476
|
-
entries.every(
|
|
476
|
+
entries.every(
|
|
477
|
+
([key, guard]) => hasOwnPropertyKey(obj, key) && guard(obj[key])
|
|
478
|
+
)
|
|
477
479
|
);
|
|
478
480
|
var hasValidOptionalKeys = (obj, entries) => (
|
|
479
481
|
// WHY: Optional keys are validated only when present. Missing keys stay valid
|
package/dist/index.mjs
CHANGED
|
@@ -369,7 +369,9 @@ var isOptionalSchemaField = define(
|
|
|
369
369
|
var hasRequiredKeys = (obj, entries) => (
|
|
370
370
|
// WHY: Required fields must be own properties; inherited values should not
|
|
371
371
|
// satisfy a schema because `struct` models object payload shape, not prototype chains.
|
|
372
|
-
entries.every(
|
|
372
|
+
entries.every(
|
|
373
|
+
([key, guard]) => hasOwnPropertyKey(obj, key) && guard(obj[key])
|
|
374
|
+
)
|
|
373
375
|
);
|
|
374
376
|
var hasValidOptionalKeys = (obj, entries) => (
|
|
375
377
|
// WHY: Optional keys are validated only when present. Missing keys stay valid
|