is-kit 1.16.1 → 1.16.2
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.js +16 -2
- package/dist/index.mjs +16 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -874,8 +874,22 @@ const assertValidSchemaKeys = (schema) => {
|
|
|
874
874
|
if (!hasOnlyEnumerableOwnStringKeys(schema) || hasInheritedStringKeys(schema)) throw new TypeError("struct schema fields must be own enumerable string keys");
|
|
875
875
|
};
|
|
876
876
|
const isOptionalSchemaField = define((field) => isObject(field) && field.optional === true && isFunction(field.guard));
|
|
877
|
-
const hasRequiredKeys = (obj, entries) =>
|
|
878
|
-
|
|
877
|
+
const hasRequiredKeys = (obj, entries) => {
|
|
878
|
+
for (const entry of entries) {
|
|
879
|
+
const key = entry[0];
|
|
880
|
+
const guard = entry[1];
|
|
881
|
+
if (!hasOwnPropertyKey(obj, key) || !guard(obj[key])) return false;
|
|
882
|
+
}
|
|
883
|
+
return true;
|
|
884
|
+
};
|
|
885
|
+
const hasValidOptionalKeys = (obj, entries) => {
|
|
886
|
+
for (const entry of entries) {
|
|
887
|
+
const key = entry[0];
|
|
888
|
+
const guard = entry[1];
|
|
889
|
+
if (hasOwnPropertyKey(obj, key) && !guard(obj[key])) return false;
|
|
890
|
+
}
|
|
891
|
+
return true;
|
|
892
|
+
};
|
|
879
893
|
const hasOnlyAllowedKeys = (obj, allowed) => Object.keys(obj).every((key) => allowed.has(key));
|
|
880
894
|
const hasOnlyRequiredKeys = (obj, schemaKeys, allowed) => {
|
|
881
895
|
const keys = Object.keys(obj);
|
package/dist/index.mjs
CHANGED
|
@@ -873,8 +873,22 @@ const assertValidSchemaKeys = (schema) => {
|
|
|
873
873
|
if (!hasOnlyEnumerableOwnStringKeys(schema) || hasInheritedStringKeys(schema)) throw new TypeError("struct schema fields must be own enumerable string keys");
|
|
874
874
|
};
|
|
875
875
|
const isOptionalSchemaField = define((field) => isObject(field) && field.optional === true && isFunction(field.guard));
|
|
876
|
-
const hasRequiredKeys = (obj, entries) =>
|
|
877
|
-
|
|
876
|
+
const hasRequiredKeys = (obj, entries) => {
|
|
877
|
+
for (const entry of entries) {
|
|
878
|
+
const key = entry[0];
|
|
879
|
+
const guard = entry[1];
|
|
880
|
+
if (!hasOwnPropertyKey(obj, key) || !guard(obj[key])) return false;
|
|
881
|
+
}
|
|
882
|
+
return true;
|
|
883
|
+
};
|
|
884
|
+
const hasValidOptionalKeys = (obj, entries) => {
|
|
885
|
+
for (const entry of entries) {
|
|
886
|
+
const key = entry[0];
|
|
887
|
+
const guard = entry[1];
|
|
888
|
+
if (hasOwnPropertyKey(obj, key) && !guard(obj[key])) return false;
|
|
889
|
+
}
|
|
890
|
+
return true;
|
|
891
|
+
};
|
|
878
892
|
const hasOnlyAllowedKeys = (obj, allowed) => Object.keys(obj).every((key) => allowed.has(key));
|
|
879
893
|
const hasOnlyRequiredKeys = (obj, schemaKeys, allowed) => {
|
|
880
894
|
const keys = Object.keys(obj);
|
package/package.json
CHANGED