"use strict"; const allowExtraProperties = require("./"); const { validateValue } = require("@validatem/core"); const hasShape = require("@validatem/has-shape"); const isString = require("@validatem/is-string"); let object = { foo: "bar", baz: "qux" }; let resultA = validateValue(object, allowExtraProperties({ foo: isString })); // { foo: 'bar', baz: 'qux' } console.log(resultA); // Also works with explicit hasShape! let resultB = validateValue(object, allowExtraProperties(hasShape({ foo: isString }))); // { foo: 'bar', baz: 'qux' } console.log(resultB); // Without allowExtraProperties, we'd get an error let resultC = validateValue(object, { foo: isString }); /* AggregrateValidationError: One or more validation errors occurred: - At (root): Encountered an unexpected property 'baz' */ console.log(resultC); // Never reached