{"id":18256181,"url":"https://github.com/serapath/object-valid","last_synced_at":"2025-04-08T22:27:04.231Z","repository":{"id":57312829,"uuid":"95493030","full_name":"serapath/object-valid","owner":"serapath","description":"tiny object validation library","archived":false,"fork":false,"pushed_at":"2017-06-27T00:31:24.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T09:26:23.314Z","etag":null,"topics":["arguments","validation"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/object-valid","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/serapath.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-26T21:59:06.000Z","updated_at":"2017-06-26T23:00:41.000Z","dependencies_parsed_at":"2022-09-20T23:02:44.875Z","dependency_job_id":null,"html_url":"https://github.com/serapath/object-valid","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serapath%2Fobject-valid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serapath%2Fobject-valid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serapath%2Fobject-valid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serapath%2Fobject-valid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serapath","download_url":"https://codeload.github.com/serapath/object-valid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247937279,"owners_count":21021222,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arguments","validation"],"created_at":"2024-11-05T10:20:28.442Z","updated_at":"2025-04-08T22:27:04.210Z","avatar_url":"https://github.com/serapath.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# object-valid\ntiny deep object validation library\n\n# usage\n`npm install object-valid`\n\n```js\nvar validate = require('object-valid')\n\n/******************************************************************************\n  define type tester\n******************************************************************************/\nvar spec_Ax = {\n  x: function isAnything (x) { return true } // property x must exist, but can be anything\n}\n\nvar spec_Ay = {\n  y: {\n    b: function isFunction (x) { return typeof x === 'boolean'},\n    x: function isFunction (x) { return typeof x === 'number'},\n    z: function isFunction (x) { return typeof x === 'string'},\n    o: function isObject (x) { return typeof x === 'object' \u0026\u0026 x !== null },\n    f: function isFunction (x) { return typeof x === 'function'},\n    a: Array.isArray, // type is function name\n    u: function isUndefined (x) { return x === undefined },\n    n: function isNull (x) { return x === null }\n  }\n}\n\nvar spec_B = {\n  x: { y: { z: function array3 (x) { return Array.isArray(x) \u0026\u0026 x.length \u003e 3 } } },\n  y: function isAnything (x) { return true }\n}\n\nvar typeAx = validate(spec_Ax)\nvar typeAy = validate(spec_Ay)\nvar typeB = validate(spec_B)\n\n/******************************************************************************\n  some objects\n******************************************************************************/\nvar A = {\n  x: undefined,\n  y: {\n    b: false,\n    x: 0,\n    z: '',\n    o: {},\n    f: function () {},\n    a: [],\n    n: null,\n    u: undefined\n  }\n}\n\nvar B = {\n  x : { y: { z: [1,2,3,4] } },\n  y : function () {}\n}\n/******************************************************************************\n  validate objects\n******************************************************************************/\ntypeAx(A) // throws if object doesnt pass specification\ntypeAy(A) // throws if object doesnt pass specification\ntypeB(B) // throws if object doesnt pass specification\n\n```\n\n# related\n* [x-is](https://www.npmjs.com/package/x-is) can be used to define an object spec\n\n# inspired by\n* [object-validate](https://www.npmjs.com/package/object-validate)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserapath%2Fobject-valid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserapath%2Fobject-valid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserapath%2Fobject-valid/lists"}