{"id":20881296,"url":"https://github.com/peakchen90/easy-object-validator","last_synced_at":"2025-05-12T16:32:38.289Z","repository":{"id":32918148,"uuid":"146180221","full_name":"peakchen90/easy-object-validator","owner":"peakchen90","description":"深度校验一个值是否合法","archived":false,"fork":false,"pushed_at":"2023-01-03T15:17:05.000Z","size":1034,"stargazers_count":5,"open_issues_count":16,"forks_count":3,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-18T20:55:59.456Z","etag":null,"topics":["js","node","object","object-validator","validate","validation","validator"],"latest_commit_sha":null,"homepage":"https://peakchen90.github.io/easy-object-validator/index.html","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/peakchen90.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2018-08-26T12:50:32.000Z","updated_at":"2022-04-02T02:19:03.000Z","dependencies_parsed_at":"2023-01-14T22:39:55.882Z","dependency_job_id":null,"html_url":"https://github.com/peakchen90/easy-object-validator","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/peakchen90%2Feasy-object-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peakchen90%2Feasy-object-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peakchen90%2Feasy-object-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peakchen90%2Feasy-object-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peakchen90","download_url":"https://codeload.github.com/peakchen90/easy-object-validator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253777055,"owners_count":21962622,"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":["js","node","object","object-validator","validate","validation","validator"],"created_at":"2024-11-18T07:24:23.910Z","updated_at":"2025-05-12T16:32:37.929Z","avatar_url":"https://github.com/peakchen90.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# easy-object-validator\n深度校验一个值是否合法\n\n\n[![Travis (.org) branch](https://img.shields.io/travis/peakchen90/easy-object-validator/master.svg)](https://travis-ci.org/peakchen90/easy-object-validator)\n[![Codecov](https://img.shields.io/codecov/c/github/peakchen90/easy-object-validator.svg)](https://codecov.io/gh/peakchen90/easy-object-validator)\n[![npm](https://img.shields.io/npm/v/easy-object-validator.svg)](https://www.npmjs.com/package/easy-object-validator)\n[![npm](https://img.shields.io/npm/dt/easy-object-validator.svg)](https://www.npmjs.com/package/easy-object-validator)\n[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/peakchen90/easy-object-validator/blob/master/LICENSE)\n\n\n\u003e [更新日志](./CHANGELOG.md)\n\n当前文档版本是2.x，API不兼容1.x版本，点击查看[1.x文档](https://github.com/peakchen90/easy-object-validator/blob/1.x/README.md)\n\n## Features\n- 支持 Node、浏览器端完美运行\n- 无任何依赖，代码压缩后仅3kb\n- 支持深度对象校验，提供的API友好、易用\n- 支持自定义校验方法扩展\n\n## 安装\n```bash\nnpm i -S easy-object-validator\n\n# 构建\nnpm run build\n# 单元测试\nnpm run test\n```\n\n## 快速开始\n```js\nimport validator from 'easy-object-validator'\n\nconst obj = {\n  foo: 123,\n  bar: 'hello',\n  child: {\n    foo: true,\n    bar: [1, 2, 3, 4],\n    child: {\n      bar: null\n    }\n  }\n};\n\nvalidator(obj, {\n  foo: validator.test(/^\\d+$/),\n  bar: validator.string.length(5),\n  child: {\n   foo: validator.boolean.isRequired,\n   bar: validator.array.length(4),\n   child: validator.shape({\n      bar: validator.isEmpty\n   })\n  }\n})\n// true\n```\n\n## API\n\n\u003e validator 的校验规则基于 Validate 类\n\n[API参考](https://peakchen90.github.io/easy-object-validator/index.html)\n\n## 结语\n用得不爽就造轮子😶，欢迎提issues或PR\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeakchen90%2Feasy-object-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeakchen90%2Feasy-object-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeakchen90%2Feasy-object-validator/lists"}