{"id":23536456,"url":"https://github.com/ethan7g/verif","last_synced_at":"2025-05-14T23:08:21.848Z","repository":{"id":57391646,"uuid":"179009156","full_name":"ethan7g/verif","owner":"ethan7g","description":"Secure data validation in JS","archived":false,"fork":false,"pushed_at":"2019-05-02T03:22:39.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-17T06:44:18.610Z","etag":null,"topics":["data","data-integrity","data-structures","data-validation","data-validator","js","json","nodejs"],"latest_commit_sha":null,"homepage":"","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/ethan7g.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":"2019-04-02T06:00:13.000Z","updated_at":"2020-09-20T17:02:13.000Z","dependencies_parsed_at":"2022-09-19T06:10:19.377Z","dependency_job_id":null,"html_url":"https://github.com/ethan7g/verif","commit_stats":null,"previous_names":["ethan7g/verif","ethanent/verif"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethan7g%2Fverif","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethan7g%2Fverif/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethan7g%2Fverif/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethan7g%2Fverif/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ethan7g","download_url":"https://codeload.github.com/ethan7g/verif/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254243363,"owners_count":22038046,"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":["data","data-integrity","data-structures","data-validation","data-validator","js","json","nodejs"],"created_at":"2024-12-26T02:27:46.018Z","updated_at":"2025-05-14T23:08:16.839Z","avatar_url":"https://github.com/ethan7g.png","language":"JavaScript","readme":"# verif\n\u003e Secure data validation in JS\n\n[GitHub](https://github.com/ethanent/verif) | [NPM](https://www.npmjs.com/package/verif)\n\n## Install\n\n```\nnpm i verif\n```\n\n```js\nconst {Validator, Range} = require('verif')\n```\n\n## Usage\n\n### Create a validator\n\n```js\nconst myValidator = new Validator({\n\t'type': 'object',\n\t'props': {\n\t\t'name': {\n\t\t\t'type': 'string',\n\t\t\t'length': Range(3, 23)\n\t\t},\n\t\t'age': {\n\t\t\t'type': 'number',\n\t\t\t'value': Range(5, 4000)\n\t\t}\n\t}\n})\n```\n\n### Test with a validator\n\n```js\nmyValidator.test({\n\t'name': 'Tester',\n\t'age': 17\n})\n\n// This will not throw; data is acceptable.\n```\n\n```js\nmyValidator.test({\n\t'name': 'Tester',\n\t'age': 4\n})\n\n// This will throw an error:\n// Error: Number value 4 out of bounds. Expected in [5, 4000]\n```\n\n### Validate with a validator\n\n```js\nconst res = myValidator.validate({\n\t'name': 'Tester',\n\t'age': 4\n})\n\n// This will return information about the validation:\n/*\n{\n\tpassed: false,\n\tmessage: 'Number value 4 out of bounds. Expected in [5, 4000]',\n\tpath: '/age/'\n}\n*/\n```\n\n### Create a range\n\n```js\n// new Range(min: number, max: number, inclusive: boolean)\n\n\nnew Range(4, 7, false)\n// Exclusive range (4, 7)\n\nnew Range(6, 10, true)\nnew Range (6, 10)\n// Inclusive range [6, 10]\n```\n\n## Properties of types\n\nFor all validations, a `type` must be specified.\n\n### number\n\n- `Range` value\n\n\tPermitted number value range\n\n### string\n\n- `Range` length\n\n\tPermitted string length range\n\n- `RegEx` test\n\n\tMandatory string regular expression test\n\n### array\n\n- `Range` length\n\n\tPermitted array length range\n\n- `schema` items\n\n\tSchema for item testing\n\n### object\n\n- `Object[schema]` props\n\n\tSchemas for testing individual properties\n\n- `boolean` allowExtraProps\n\n\tPermit the inclusion of additional properties not defined in `props`\n\n\tDefault: `false`\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethan7g%2Fverif","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fethan7g%2Fverif","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethan7g%2Fverif/lists"}