{"id":32948876,"url":"https://github.com/lyonnee/hvalid","last_synced_at":"2026-01-14T22:58:45.698Z","repository":{"id":233554300,"uuid":"787222324","full_name":"lyonnee/hvalid","owner":"lyonnee","description":"hvalid is a lightweight validation library written in Go language.(一个用Go语言编写的轻量级验证库)","archived":false,"fork":false,"pushed_at":"2025-06-05T06:54:11.000Z","size":67,"stargazers_count":14,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-11-12T21:02:47.954Z","etag":null,"topics":["golang","validation"],"latest_commit_sha":null,"homepage":"","language":"Go","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/lyonnee.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-16T05:52:07.000Z","updated_at":"2025-10-28T01:24:54.000Z","dependencies_parsed_at":"2024-06-19T11:28:06.245Z","dependency_job_id":"b3a0a77e-6e04-47c1-b482-580cfa9cf28b","html_url":"https://github.com/lyonnee/hvalid","commit_stats":null,"previous_names":["lyonnee/hval","lyonnee/hvalid"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/lyonnee/hvalid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyonnee%2Fhvalid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyonnee%2Fhvalid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyonnee%2Fhvalid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyonnee%2Fhvalid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lyonnee","download_url":"https://codeload.github.com/lyonnee/hvalid/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyonnee%2Fhvalid/sbom","scorecard":{"id":607468,"data":{"date":"2025-08-11","repo":{"name":"github.com/lyonnee/hvalid","commit":"34f94fc3cc5b976fc6e4b7ce7a6bf5953457c8ee"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.7,"checks":[{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"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":3,"reason":"4 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 3","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":"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":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","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":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/lyonnee/hvalid/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/lyonnee/hvalid/ci.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/lyonnee/hvalid/ci.yml/main?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned"],"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":"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":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"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":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"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":"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"}}]},"last_synced_at":"2025-08-21T01:55:39.012Z","repository_id":233554300,"created_at":"2025-08-21T01:55:39.013Z","updated_at":"2025-08-21T01:55:39.013Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28437754,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T22:37:52.437Z","status":"ssl_error","status_checked_at":"2026-01-14T22:37:31.496Z","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":["golang","validation"],"created_at":"2025-11-12T20:00:35.672Z","updated_at":"2026-01-14T22:58:45.679Z","avatar_url":"https://github.com/lyonnee.png","language":"Go","readme":"\u003cdiv align=\"center\"\u003e\n\u003c/br\u003e\n\n# hvalid\n\n| English | [中文](README_zh.md) |\n| --- | --- |\n\n`hvalid` is a lightweight validation library written in Go language. It provides a custom validator interface and a series of common validation functions to help developers quickly implement data validation.\n\n\u003c/div\u003e\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/lyonnee/hvalid)](https://goreportcard.com/report/github.com/lyonnee/hvalid)\n![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/lyonnee/hvalid)\n[![codecov](https://codecov.io/gh/lyonnee/hvalid/graph/badge.svg?token=2LT7V180W9)](https://codecov.io/gh/lyonnee/hvalid)\n\n## Features\n- Generic support: Can validate any type of data, including basic types, structs, slices, etc.\n- Easy to use: Offers a concise API for developers to quickly perform parameter validation.\n- Extensible: Allows custom validation rules to meet different validation needs.\n- Friendly error messages: Returns clear error messages when validation fails, making it easy for developers to locate issues.\n\n## Installation\nInstall using the `go get` command:\n```bash\ngo get github.com/lyonnee/hvalid\n```\n\n### Usage Examples\n\n#### Basic Type Validation\n\n```go\nimport (\n\t\"errors\"\n\t\"github.com/lyonnee/hvalid\"\n)\n\nfunc main() {\n\t// Validate string length\n\terr := hvalid.Validate[string](\"hello\", hvalid.MinLen[string](3))\n\tif err != nil {\n\t\t// Handle error\n\t}\n\n\t// Validate number range\n\terr = hvalid.Validate[int](10, hvalid.Min(5), hvalid.Max(15))\n\tif err != nil {\n\t\t// Handle error\n\t}\n}\n```\n\n#### Struct Validation\n\n```go\ntype User struct {\n\tName  string\n\tEmail string\n\tAge   int\n}\n\nfunc UserValidator() hvalid.ValidatorFunc[User] {\n\treturn hvalid.ValidatorFunc[User](func(user User) error {\n\t\tif user.Age \u003c 18 {\n\t\t\treturn errors.New(\"Age must be greater than 18\")\n\t\t}\n\n\t\treturn hvalid.Validate[string](user.Email, hvalid.Email())\n\t})\n}\n\nfunc main() {\n\tuser := User{\n\t\tName:  \"Zhang San\",\n\t\tEmail: \"zhangsan@example.com\",\n\t\tAge:   20,\n\t}\n\n\terr := hvalid.Validate[User](user, UserValidator())\n\tif err != nil {\n\t\t// Handle error\n\t}\n}\n```\n\n#### Custom Validation Rules\n\n```go\nfunc IsPositive(errMsg ...string) hvalid.ValidatorFunc[int] {\n\treturn hvalid.ValidatorFunc[int](func(num int) error {\n\t\tif num \u003c= 0 {\n\t\t\tif len(errMsg) \u003e 0 {\n\t\t\t\treturn errors.New(errMsg[0])\n\t\t\t}\n\t\t\treturn errors.New(\"The number must be positive\")\n\t\t}\n\t\treturn nil\n\t})\n}\n\nfunc main() {\n\terr := hvalid.Validate[int](10, IsPositive())\n\tif err != nil {\n\t\t// Handle error\n\t}\n}\n```\n\n## Testing\nThe project includes unit tests, run all tests with the `go test` command:\n```bash\ngo test ./...\n```\n\n## Contributing\nIssues and pull requests are welcome to improve `hvalid`.\n\n## License\n`hvalid` is released under the MIT License. See the [LICENSE](LICENSE) file for more information.\n","funding_links":[],"categories":["Validation","验证"],"sub_categories":["Utility/Miscellaneous","实用程序/Miscellaneous"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flyonnee%2Fhvalid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flyonnee%2Fhvalid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flyonnee%2Fhvalid/lists"}