{"id":13487489,"url":"https://github.com/hexindai/egg-valid","last_synced_at":"2026-01-16T06:34:17.267Z","repository":{"id":57220819,"uuid":"126446842","full_name":"hexindai/egg-valid","owner":"hexindai","description":"👮 Validation plugin for eggjs","archived":false,"fork":false,"pushed_at":"2018-07-03T05:19:41.000Z","size":57,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-18T08:37:29.539Z","etag":null,"topics":["egg","egg-plugin","validation"],"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/hexindai.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":"2018-03-23T07:11:28.000Z","updated_at":"2021-12-01T09:39:31.000Z","dependencies_parsed_at":"2022-08-29T04:01:37.554Z","dependency_job_id":null,"html_url":"https://github.com/hexindai/egg-valid","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/hexindai/egg-valid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexindai%2Fegg-valid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexindai%2Fegg-valid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexindai%2Fegg-valid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexindai%2Fegg-valid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hexindai","download_url":"https://codeload.github.com/hexindai/egg-valid/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexindai%2Fegg-valid/sbom","scorecard":{"id":462865,"data":{"date":"2025-08-11","repo":{"name":"github.com/hexindai/egg-valid","commit":"8050a53ec45da2281073b729b9c721fd12ebda15"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 1 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T11:37:35.197Z","repository_id":57220819,"created_at":"2025-08-19T11:37:35.197Z","updated_at":"2025-08-19T11:37:35.197Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28477865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["egg","egg-plugin","validation"],"created_at":"2024-07-31T18:00:59.969Z","updated_at":"2026-01-16T06:34:17.227Z","avatar_url":"https://github.com/hexindai.png","language":"JavaScript","readme":"# egg-valid\n\nA better Validation egg plugin based on [@killara/validation](https://github.com/killara/validation)\n\n[![NPM version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![David deps][david-image]][david-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/egg-valid.svg\n[npm-url]: https://npmjs.org/package/egg-valid\n[travis-image]: https://img.shields.io/travis/hexindai/egg-valid.svg\n[travis-url]: https://travis-ci.org/hexindai/egg-valid\n[codecov-image]: https://img.shields.io/codecov/c/github/hexindai/egg-valid.svg\n[codecov-url]: https://codecov.io/github/hexindai/egg-valid?branch=master\n[david-image]: https://img.shields.io/david/hexindai/egg-valid.svg\n[david-url]: https://david-dm.org/hexindai/egg-valid\n[snyk-image]: https://snyk.io/test/npm/egg-valid/badge.svg\n[snyk-url]: https://snyk.io/test/npm/egg-valid\n[download-image]: https://img.shields.io/npm/dm/egg-valid.svg\n[download-url]: https://npmjs.org/package/egg-valid\n\n## Install\n\n```bash\n$ npm i egg-valid -S\n```\n\n## Usage\n\n```js\n// config\nexports.valid = {\n  enable: true,\n  package: 'egg-valid',\n};\n// controller\nclass HomeController extends Controller {\n  async index() {\n    const { app, ctx } = this;\n    const rule = { username: 'required|alpha' };\n    const errors = await app.validator.validate(ctx.request.body, rule)\n    // ...\n  }\n}\n```\n\n## Rule\n\n### Derived from [@killara/validation](https://github.com/killara/validation)\n\n* accepted\n  * string style: `field: 'accepted'`\n  * object style: `field: { accepted: true }`\n* alpha\n  * string style: `field: 'alpha:6'` or `field: 'alpha:len=6'`\n  * object style: `field: { alpha: { len: 6 } }`\n* confirmed\n\n  Rule `confirmed`: the `field` need to have the same value as the value that be filled by `field_confirmation`. We can change `field_confirmation` to any names with `confirmed:\"custom\"`\n\n  * string style: `field: 'confirmed'` or `field: 'confirmed:\"custom_field_name\"'`\n  * object style: `field: { confirmed: \"custom_field_name\" }`\n* date\n  * string style: `field: 'date'`\n  * object style: `field: { date: true }`\n* datetime\n  * string style: `field: 'datetime'`\n  * object style: `field: { datetime: true }`\n* time\n  * string style: `field: 'time'`\n  * object style: `field: { time: true }`\n* email\n  * string style: `field: 'email:true'`\n  * object style: `field: { email: true }`\n* in\n  * `array` style: `field: [ 'basketball', 'football' ]`\n  * object style: `field: { in: [ 'basketball', 'football' ] }`\n* money\n  * string style: `field: 'money'` or `field: 'money:0'` `field: 'money:2'` (default)\n  * object style: `field: { money: { decimal: true } }` or `field: { money: { decimal: 0 } }` or `field: { money: { decimal: 2 } }`\n* numeric\n  * string style: `field: 'numeric:6'` or `field: 'numeric:len=6'`\n  * object style: `field: { numeric: { len: 6 } }`\n* regexp\n  * string style: `field: 'regexp:\"^123456$\"'`\n  * object style: `field: { regexp: new RegExp(/abc/, 'i') }` or `field: { regexp: /^[0-9a-zA-z]{8,16}$/ }`\n* required\n  * string style: `field: 'required'` or `field: 'required:true'`\n  * object style: `field: { required: true }`\n\n**[More rules](https://github.com/killara/validation)**\n\n### Custom rules\n\n* phone (currently support China phone number only)\n  * string style: `field: 'required|phone'`\n* password (length: 8-18, alphanumeric and \u0026*;+$,?#[]%)\n  * string style:`field: 'password'` or `field: 'password:min=8,max=18'` or `field: 'password:\"^[a-z0-9!()-._@#]{8,18}$\"'`\n* captcha (phone auth code)\n  * string style:`field: 'captcha'` or `field: 'captcha:6'`\n  * object style: `field: { captcha: { len: 6} }`\n\n## Messages\n\nCustomize validation messages\n\n### Via API\n\n```js\nclass HomeController extends Controller {\n  async index() {\n    const { app, ctx } = this;\n    const rule = { username: 'required|alpha:6' };\n    const messages = { 'username.alpha': '该字段应该为长度为6的字母串' };\n    const errors = await app.validator.validate(ctx.request.body, rule, messages);\n    if (errors) {\n      // ...\n    } else {\n      // ...\n    }\n  }\n}\n```\n\n### Via configuration\n\n```js\nexports.valid = {\n  rules: {\n    custom: field =\u003e context =\u003e params =\u003e {\n      // We can get `app` and `ctx` from context\n      const { app, ctx, options } = context;\n      //... return a boolean\n    }\n  },\n  messages: {\n    custom: 'a custom message...',\n  },\n};\n```\n\n## API\n\n### validation.addRule(name: string, ruleFunc: (field: string) =\u003e (context: object) =\u003e (params: object) =\u003e bool)\n* Add custom rule\n### validation.addMessage(name: string, message: string)\n* Add custom message\n\n## License\n\n[MIT](LICENSE)\n","funding_links":[],"categories":["Plugins","仓库"],"sub_categories":["插件"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexindai%2Fegg-valid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhexindai%2Fegg-valid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexindai%2Fegg-valid/lists"}