{"_id":"@humanwhocodes/object-schema","_rev":"3279798","name":"@humanwhocodes/object-schema","description":"An object schema merger/validator","dist-tags":{"latest":"2.0.3"},"maintainers":[{"name":"nzakas","email":""}],"time":{"modified":"2024-04-08T03:20:22.000Z","created":"2019-02-03T16:36:29.222Z","2.0.3":"2024-04-01T20:31:25.486Z","2.0.2":"2024-01-10T19:12:31.106Z","2.0.1":"2023-10-20T14:54:27.190Z","2.0.0":"2023-10-18T15:31:20.784Z","1.2.1":"2021-11-02T19:00:15.389Z","1.2.0":"2021-03-20T02:01:51.735Z","1.1.1":"2019-03-21T16:50:43.156Z","1.1.0":"2019-03-20T16:12:40.413Z","1.0.0":"2019-03-18T22:14:49.328Z","0.2.0":"2019-03-14T21:45:23.049Z","0.1.0":"2019-02-03T16:36:29.222Z"},"users":{},"author":{"name":"Nicholas C. Zakas"},"repository":{"type":"git","url":"git+https://github.com/humanwhocodes/object-schema.git"},"versions":{"2.0.3":{"name":"@humanwhocodes/object-schema","version":"2.0.3","description":"An object schema merger/validator","main":"src/index.js","directories":{"test":"tests"},"scripts":{"test":"mocha tests/"},"repository":{"type":"git","url":"git+https://github.com/humanwhocodes/object-schema.git"},"keywords":["object","validation","schema","merge"],"author":{"name":"Nicholas C. Zakas"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/humanwhocodes/object-schema/issues"},"homepage":"https://github.com/humanwhocodes/object-schema#readme","devDependencies":{"chai":"^4.2.0","eslint":"^5.13.0","mocha":"^5.2.0"},"gitHead":"ca5d5b15b81c7a4abddaa6a0d079412b4dad2b82","_id":"@humanwhocodes/object-schema@2.0.3","_nodeVersion":"12.22.12","_npmVersion":"6.14.16","dist":{"shasum":"4a2868d75d6d6963e423bcf90b7fd1be343409d3","size":6184,"noattachment":false,"key":"/@humanwhocodes/object-schema/-/@humanwhocodes/object-schema-2.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/@humanwhocodes/object-schema/download/@humanwhocodes/object-schema-2.0.3.tgz"},"_npmUser":{"name":"nzakas","email":"nicholas@nczconsulting.com"},"maintainers":[{"name":"nzakas","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/object-schema_2.0.3_1712003485293_0.24242754542965206"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-04-01T20:31:25.486Z","publish_time":1712003485486,"_source_registry_name":"default","_cnpm_publish_time":1712003485486},"2.0.2":{"name":"@humanwhocodes/object-schema","version":"2.0.2","description":"An object schema merger/validator","main":"src/index.js","directories":{"test":"tests"},"scripts":{"test":"mocha tests/"},"repository":{"type":"git","url":"git+https://github.com/humanwhocodes/object-schema.git"},"keywords":["object","validation","schema","merge"],"author":{"name":"Nicholas C. Zakas"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/humanwhocodes/object-schema/issues"},"homepage":"https://github.com/humanwhocodes/object-schema#readme","devDependencies":{"chai":"^4.2.0","eslint":"^5.13.0","mocha":"^5.2.0"},"gitHead":"8898ac6c6d16b3ddf4697acb4c30d8b95502bcc4","_id":"@humanwhocodes/object-schema@2.0.2","_nodeVersion":"12.22.12","_npmVersion":"6.14.16","dist":{"shasum":"d9fae00a2d5cb40f92cfe64b47ad749fbc38f917","size":9591,"noattachment":false,"key":"/@humanwhocodes/object-schema/-/@humanwhocodes/object-schema-2.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/@humanwhocodes/object-schema/download/@humanwhocodes/object-schema-2.0.2.tgz"},"_npmUser":{"name":"nzakas","email":"nicholas@nczconsulting.com"},"maintainers":[{"name":"nzakas","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/object-schema_2.0.2_1704913950929_0.60810795813103"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-01-10T19:12:31.106Z","publish_time":1704913951106,"_source_registry_name":"default","_cnpm_publish_time":1704913951106},"2.0.1":{"name":"@humanwhocodes/object-schema","version":"2.0.1","description":"An object schema merger/validator","main":"src/index.js","directories":{"test":"tests"},"scripts":{"test":"mocha tests/"},"repository":{"type":"git","url":"git+https://github.com/humanwhocodes/object-schema.git"},"keywords":["object","validation","schema","merge"],"author":{"name":"Nicholas C. Zakas"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/humanwhocodes/object-schema/issues"},"homepage":"https://github.com/humanwhocodes/object-schema#readme","devDependencies":{"chai":"^4.2.0","eslint":"^5.13.0","mocha":"^5.2.0"},"gitHead":"2f248ebfa8b4d6641a3ff61317b152f9709fc594","_id":"@humanwhocodes/object-schema@2.0.1","_nodeVersion":"12.22.12","_npmVersion":"6.14.16","dist":{"shasum":"e5211452df060fa8522b55c7b3c0c4d1981cb044","size":9503,"noattachment":false,"key":"/@humanwhocodes/object-schema/-/@humanwhocodes/object-schema-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/@humanwhocodes/object-schema/download/@humanwhocodes/object-schema-2.0.1.tgz"},"_npmUser":{"name":"nzakas","email":"nicholas@nczconsulting.com"},"maintainers":[{"name":"nzakas","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/object-schema_2.0.1_1697813666996_0.38033491057458746"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-10-20T14:54:27.190Z","publish_time":1697813667190,"_source_registry_name":"default","_cnpm_publish_time":1697813667190},"2.0.0":{"name":"@humanwhocodes/object-schema","version":"2.0.0","description":"An object schema merger/validator","main":"src/index.js","directories":{"test":"tests"},"scripts":{"test":"mocha tests/"},"repository":{"type":"git","url":"git+https://github.com/humanwhocodes/object-schema.git"},"keywords":["object","validation","schema","merge"],"author":{"name":"Nicholas C. Zakas"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/humanwhocodes/object-schema/issues"},"homepage":"https://github.com/humanwhocodes/object-schema#readme","devDependencies":{"chai":"^4.2.0","eslint":"^5.13.0","mocha":"^5.2.0"},"gitHead":"3627e87ed86b0cc166cff73208370b2e3da943f3","_id":"@humanwhocodes/object-schema@2.0.0","_nodeVersion":"12.22.12","_npmVersion":"6.14.16","dist":{"shasum":"04ad39d82176c7da1591c81e78b993cffd8348d8","size":9399,"noattachment":false,"key":"/@humanwhocodes/object-schema/-/@humanwhocodes/object-schema-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@humanwhocodes/object-schema/download/@humanwhocodes/object-schema-2.0.0.tgz"},"_npmUser":{"name":"nzakas","email":"nicholas@nczconsulting.com"},"maintainers":[{"name":"nzakas","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/object-schema_2.0.0_1697643080437_0.30356410636978626"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-10-18T15:31:20.784Z","publish_time":1697643080784,"_source_registry_name":"default","_cnpm_publish_time":1697643080784},"1.2.1":{"name":"@humanwhocodes/object-schema","version":"1.2.1","description":"An object schema merger/validator","main":"src/index.js","directories":{"test":"tests"},"scripts":{"test":"mocha tests/"},"repository":{"type":"git","url":"git+https://github.com/humanwhocodes/object-schema.git"},"keywords":["object","validation","schema","merge"],"author":{"name":"Nicholas C. Zakas"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/humanwhocodes/object-schema/issues"},"homepage":"https://github.com/humanwhocodes/object-schema#readme","devDependencies":{"chai":"^4.2.0","eslint":"^5.13.0","mocha":"^5.2.0"},"gitHead":"98308bc9bf05e491df18b192e614d7ba02d50a68","_id":"@humanwhocodes/object-schema@1.2.1","_nodeVersion":"12.22.7","_npmVersion":"6.14.15","dist":{"shasum":"b520529ec21d8e5945a1851dfd1c32e94e39ff45","size":8903,"noattachment":false,"key":"/@humanwhocodes/object-schema/-/@humanwhocodes/object-schema-1.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/@humanwhocodes/object-schema/download/@humanwhocodes/object-schema-1.2.1.tgz"},"_npmUser":{"name":"nzakas","email":"nicholas@nczconsulting.com"},"maintainers":[{"name":"nzakas","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/object-schema_1.2.1_1635879615243_0.028928641075219863"},"_hasShrinkwrap":false,"publish_time":1635879615389,"_cnpm_publish_time":1635879615389},"1.2.0":{"name":"@humanwhocodes/object-schema","version":"1.2.0","description":"An object schema merger/validator","main":"src/index.js","directories":{"test":"tests"},"scripts":{"test":"mocha tests/"},"repository":{"type":"git","url":"git+https://github.com/humanwhocodes/object-schema.git"},"keywords":["object","validation","schema","merge"],"author":{"name":"Nicholas C. Zakas"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/humanwhocodes/object-schema/issues"},"homepage":"https://github.com/humanwhocodes/object-schema#readme","devDependencies":{"chai":"^4.2.0","eslint":"^5.13.0","mocha":"^5.2.0"},"gitHead":"e053c89308b982af4fc654ae68035240830a5b8b","_id":"@humanwhocodes/object-schema@1.2.0","_nodeVersion":"14.15.1","_npmVersion":"6.14.8","dist":{"shasum":"87de7af9c231826fdd68ac7258f77c429e0e5fcf","size":7758,"noattachment":false,"key":"/@humanwhocodes/object-schema/-/@humanwhocodes/object-schema-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@humanwhocodes/object-schema/download/@humanwhocodes/object-schema-1.2.0.tgz"},"_npmUser":{"name":"nzakas","email":"nicholas@nczconsulting.com"},"maintainers":[{"name":"nzakas","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/object-schema_1.2.0_1616205711548_0.5436041366332698"},"_hasShrinkwrap":false,"publish_time":1616205711735,"_cnpm_publish_time":1616205711735},"1.1.1":{"name":"@humanwhocodes/object-schema","version":"1.1.1","description":"An object schema merger/validator","main":"src/index.js","directories":{"test":"tests"},"scripts":{"test":"mocha tests/"},"repository":{"type":"git","url":"git+https://github.com/humanwhocodes/object-schema.git"},"keywords":["object","validation","schema","merge"],"author":{"name":"Nicholas C. Zakas"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/humanwhocodes/object-schema/issues"},"homepage":"https://github.com/humanwhocodes/object-schema#readme","devDependencies":{"chai":"^4.2.0","eslint":"^5.13.0","mocha":"^5.2.0"},"gitHead":"9dea4c0ca67e6c1518de62e64fe3ca7b077d8119","_id":"@humanwhocodes/object-schema@1.1.1","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"nzakas","email":"nicholas@nczconsulting.com"},"dist":{"shasum":"d44fa35e3d23e0da99a0e4d476c08be4345be9b8","size":5701,"noattachment":false,"key":"/@humanwhocodes/object-schema/-/@humanwhocodes/object-schema-1.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/@humanwhocodes/object-schema/download/@humanwhocodes/object-schema-1.1.1.tgz"},"maintainers":[{"name":"nzakas","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/object-schema_1.1.1_1553187043032_0.8020224056922332"},"_hasShrinkwrap":false,"publish_time":1553187043156,"_cnpm_publish_time":1553187043156},"1.1.0":{"name":"@humanwhocodes/object-schema","version":"1.1.0","description":"An object schema merger/validator","main":"src/index.js","directories":{"test":"tests"},"scripts":{"test":"mocha tests/"},"repository":{"type":"git","url":"git+https://github.com/humanwhocodes/object-schema.git"},"keywords":["object","validation","schema","merge"],"author":{"name":"Nicholas C. Zakas"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/humanwhocodes/object-schema/issues"},"homepage":"https://github.com/humanwhocodes/object-schema#readme","devDependencies":{"chai":"^4.2.0","eslint":"^5.13.0","mocha":"^5.2.0"},"gitHead":"8ff3ad4859a0569758423b06ce6bd8b748edc0a8","_id":"@humanwhocodes/object-schema@1.1.0","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"nzakas","email":"nicholas@nczconsulting.com"},"dist":{"shasum":"e1f3875d9a313dce79019c313a263648dce2a7c6","size":5559,"noattachment":false,"key":"/@humanwhocodes/object-schema/-/@humanwhocodes/object-schema-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@humanwhocodes/object-schema/download/@humanwhocodes/object-schema-1.1.0.tgz"},"maintainers":[{"name":"nzakas","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/object-schema_1.1.0_1553098360314_0.5624422683994903"},"_hasShrinkwrap":false,"publish_time":1553098360413,"_cnpm_publish_time":1553098360413},"1.0.0":{"name":"@humanwhocodes/object-schema","version":"1.0.0","description":"An object schema merger/validator","main":"src/index.js","directories":{"test":"tests"},"scripts":{"test":"mocha tests/"},"repository":{"type":"git","url":"git+https://github.com/humanwhocodes/object-schema.git"},"keywords":["object","validation","schema","merge"],"author":{"name":"Nicholas C. Zakas"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/humanwhocodes/object-schema/issues"},"homepage":"https://github.com/humanwhocodes/object-schema#readme","devDependencies":{"chai":"^4.2.0","eslint":"^5.13.0","mocha":"^5.2.0"},"gitHead":"f0757475f8bca664db1aad6b8fd108f21de1b22c","_id":"@humanwhocodes/object-schema@1.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"nzakas","email":"nicholas@nczconsulting.com"},"dist":{"shasum":"4f30c42058d11689c6f159a4820f1eee216801b3","size":5513,"noattachment":false,"key":"/@humanwhocodes/object-schema/-/@humanwhocodes/object-schema-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@humanwhocodes/object-schema/download/@humanwhocodes/object-schema-1.0.0.tgz"},"maintainers":[{"name":"nzakas","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/object-schema_1.0.0_1552947289084_0.42332081508699226"},"_hasShrinkwrap":false,"publish_time":1552947289328,"_cnpm_publish_time":1552947289328},"0.2.0":{"name":"@humanwhocodes/object-schema","version":"0.2.0","description":"An object schema merger/validator","main":"src/index.js","directories":{"test":"tests"},"scripts":{"test":"mocha tests/"},"repository":{"type":"git","url":"git+https://github.com/humanwhocodes/object-schema.git"},"keywords":["object","validation","schema","merge"],"author":{"name":"Nicholas C. Zakas"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/humanwhocodes/object-schema/issues"},"homepage":"https://github.com/humanwhocodes/object-schema#readme","devDependencies":{"chai":"^4.2.0","eslint":"^5.13.0","mocha":"^5.2.0"},"gitHead":"faa136808289fa5f41370b1f424e59bff9757cee","_id":"@humanwhocodes/object-schema@0.2.0","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"nzakas","email":"nicholas@nczconsulting.com"},"dist":{"shasum":"593eadf7cb83284e17a90f925e343cee3da22793","size":5674,"noattachment":false,"key":"/@humanwhocodes/object-schema/-/@humanwhocodes/object-schema-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@humanwhocodes/object-schema/download/@humanwhocodes/object-schema-0.2.0.tgz"},"maintainers":[{"name":"nzakas","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/object-schema_0.2.0_1552599922926_0.9817313815760178"},"_hasShrinkwrap":false,"publish_time":1552599923049,"_cnpm_publish_time":1552599923049},"0.1.0":{"name":"@humanwhocodes/object-schema","version":"0.1.0","description":"An object schema merger/validator","main":"src/index.js","directories":{"test":"tests"},"scripts":{"test":"mocha tests/"},"repository":{"type":"git","url":"git+https://github.com/humanwhocodes/object-schema.git"},"keywords":["object","validation","schema","merge"],"author":{"name":"Nicholas C. Zakas"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/humanwhocodes/object-schema/issues"},"homepage":"https://github.com/humanwhocodes/object-schema#readme","devDependencies":{"chai":"^4.2.0","eslint":"^5.13.0","mocha":"^5.2.0"},"gitHead":"6dfe3a9a16499b187e68838fe3a6060c28e93ae4","_id":"@humanwhocodes/object-schema@0.1.0","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"nzakas","email":"nicholas@nczconsulting.com"},"dist":{"shasum":"10b02066ad12e6ef1c791229afbdc0dce6413a53","size":4553,"noattachment":false,"key":"/@humanwhocodes/object-schema/-/@humanwhocodes/object-schema-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@humanwhocodes/object-schema/download/@humanwhocodes/object-schema-0.1.0.tgz"},"maintainers":[{"name":"nzakas","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/object-schema_0.1.0_1549211789120_0.09584111731713851"},"_hasShrinkwrap":false,"publish_time":1549211789222,"_cnpm_publish_time":1549211789222}},"readme":"# JavaScript ObjectSchema Package\n\nby [Nicholas C. Zakas](https://humanwhocodes.com)\n\nIf you find this useful, please consider supporting my work with a [donation](https://humanwhocodes.com/donate).\n\n## Overview\n\nA JavaScript object merge/validation utility where you can define a different merge and validation strategy for each key. This is helpful when you need to validate complex data structures and then merge them in a way that is more complex than `Object.assign()`.\n\n## Installation\n\nYou can install using either npm:\n\n```\nnpm install @humanwhocodes/object-schema\n```\n\nOr Yarn:\n\n```\nyarn add @humanwhocodes/object-schema\n```\n\n## Usage\n\nUse CommonJS to get access to the `ObjectSchema` constructor:\n\n```js\nconst { ObjectSchema } = require(\"@humanwhocodes/object-schema\");\n\nconst schema = new ObjectSchema({\n\n    // define a definition for the \"downloads\" key\n    downloads: {\n        required: true,\n        merge(value1, value2) {\n            return value1 + value2;\n        },\n        validate(value) {\n            if (typeof value !== \"number\") {\n                throw new Error(\"Expected downloads to be a number.\");\n            }\n        }\n    },\n\n    // define a strategy for the \"versions\" key\n    version: {\n        required: true,\n        merge(value1, value2) {\n            return value1.concat(value2);\n        },\n        validate(value) {\n            if (!Array.isArray(value)) {\n                throw new Error(\"Expected versions to be an array.\");\n            }\n        }\n    }\n});\n\nconst record1 = {\n    downloads: 25,\n    versions: [\n        \"v1.0.0\",\n        \"v1.1.0\",\n        \"v1.2.0\"\n    ]\n};\n\nconst record2 = {\n    downloads: 125,\n    versions: [\n        \"v2.0.0\",\n        \"v2.1.0\",\n        \"v3.0.0\"\n    ]\n};\n\n// make sure the records are valid\nschema.validate(record1);\nschema.validate(record2);\n\n// merge together (schema.merge() accepts any number of objects)\nconst result = schema.merge(record1, record2);\n\n// result looks like this:\n\nconst result = {\n    downloads: 75,\n    versions: [\n        \"v1.0.0\",\n        \"v1.1.0\",\n        \"v1.2.0\",\n        \"v2.0.0\",\n        \"v2.1.0\",\n        \"v3.0.0\"\n    ]\n};\n```\n\n## Tips and Tricks\n\n### Named merge strategies\n\nInstead of specifying a `merge()` method, you can specify one of the following strings to use a default merge strategy:\n\n* `\"assign\"` - use `Object.assign()` to merge the two values into one object.\n* `\"overwrite\"` - the second value always replaces the first.\n* `\"replace\"` - the second value replaces the first if the second is not `undefined`.\n\nFor example:\n\n```js\nconst schema = new ObjectSchema({\n    name: {\n        merge: \"replace\",\n        validate() {}\n    }\n});\n```\n\n### Named validation strategies\n\nInstead of specifying a `validate()` method, you can specify one of the following strings to use a default validation strategy:\n\n* `\"array\"` - value must be an array.\n* `\"boolean\"` - value must be a boolean.\n* `\"number\"` - value must be a number.\n* `\"object\"` - value must be an object.\n* `\"object?\"` - value must be an object or null.\n* `\"string\"` - value must be a string.\n* `\"string!\"` - value must be a non-empty string.\n\nFor example:\n\n```js\nconst schema = new ObjectSchema({\n    name: {\n        merge: \"replace\",\n        validate: \"string\"\n    }\n});\n```\n\n### Subschemas\n\nIf you are defining a key that is, itself, an object, you can simplify the process by using a subschema. Instead of defining `merge()` and `validate()`, assign a `schema` key that contains a schema definition, like this:\n\n```js\nconst schema = new ObjectSchema({\n    name: {\n        schema: {\n            first: {\n                merge: \"replace\",\n                validate: \"string\"\n            },\n            last: {\n                merge: \"replace\",\n                validate: \"string\"\n            }\n        }\n    }\n});\n\nschema.validate({\n    name: {\n        first: \"n\",\n        last: \"z\"\n    }\n});\n```\n\n### Remove Keys During Merge\n\nIf the merge strategy for a key returns `undefined`, then the key will not appear in the final object. For example:\n\n```js\nconst schema = new ObjectSchema({\n    date: {\n        merge() {\n            return undefined;\n        },\n        validate(value) {\n            Date.parse(value);  // throws an error when invalid\n        }\n    }\n});\n\nconst object1 = { date: \"5/5/2005\" };\nconst object2 = { date: \"6/6/2006\" };\n\nconst result = schema.merge(object1, object2);\n\nconsole.log(\"date\" in result);  // false\n```\n\n### Requiring Another Key Be Present\n\nIf you'd like the presence of one key to require the presence of another key, you can use the `requires` property to specify an array of other properties that any key requires. For example:\n\n```js\nconst schema = new ObjectSchema();\n\nconst schema = new ObjectSchema({\n    date: {\n        merge() {\n            return undefined;\n        },\n        validate(value) {\n            Date.parse(value);  // throws an error when invalid\n        }\n    },\n    time: {\n        requires: [\"date\"],\n        merge(first, second) {\n            return second;\n        },\n        validate(value) {\n            // ...\n        }\n    }\n});\n\n// throws error: Key \"time\" requires keys \"date\"\nschema.validate({\n    time: \"13:45\"\n});\n```\n\nIn this example, even though `date` is an optional key, it is required to be present whenever `time` is present.\n\n## License\n\nBSD 3-Clause\n","_attachments":{},"homepage":"https://github.com/humanwhocodes/object-schema#readme","bugs":{"url":"https://github.com/humanwhocodes/object-schema/issues"},"license":"BSD-3-Clause"}