{"id":18345744,"url":"https://github.com/hyperf/validation","last_synced_at":"2026-03-08T13:05:55.259Z","repository":{"id":38136141,"uuid":"203755141","full_name":"hyperf/validation","owner":"hyperf","description":"Validation component for Hyperf","archived":false,"fork":false,"pushed_at":"2026-02-04T07:55:05.000Z","size":387,"stargazers_count":12,"open_issues_count":1,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-02-04T19:40:19.858Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://hyperf.io","language":"PHP","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/hyperf.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"open_collective":"hyperf","custom":"https://hyperf.wiki/#/zh-cn/donate"}},"created_at":"2019-08-22T08:57:40.000Z","updated_at":"2026-02-04T07:55:09.000Z","dependencies_parsed_at":"2023-02-01T05:05:14.277Z","dependency_job_id":"5e9939e3-af40-4098-a8a3-e4effed1e5d0","html_url":"https://github.com/hyperf/validation","commit_stats":null,"previous_names":[],"tags_count":98,"template":false,"template_full_name":null,"purl":"pkg:github/hyperf/validation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf%2Fvalidation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf%2Fvalidation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf%2Fvalidation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf%2Fvalidation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyperf","download_url":"https://codeload.github.com/hyperf/validation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperf%2Fvalidation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29771212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-24T04:01:02.180Z","status":"ssl_error","status_checked_at":"2026-02-24T03:59:49.901Z","response_time":75,"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":[],"created_at":"2024-11-05T21:09:20.612Z","updated_at":"2026-02-24T04:13:49.913Z","avatar_url":"https://github.com/hyperf.png","language":"PHP","readme":"# Hyperf Validation\n\n## About\n\n[hyperf/validation](https://github.com/hyperf/validation) 组件衍生于 `Laravel Validation` 组件的，我们对它进行了一些改造，大部分功能保持了相同。在这里感谢一下 Laravel 开发组，实现了如此强大好用的 Validation 组件。\n\n## Installation\n\n```\ncomposer require hyperf/validation\n```\n\n## Config\n\n### Publish config file\n\n```\n# 发布国际化配置，已经发布过国际化配置可以省略\nphp bin/hyperf.php vendor:publish hyperf/translation\n\nphp bin/hyperf.php vendor:publish hyperf/validation\n```\n\n### Configuration path\n\n```\nyour/config/path/autoload/translation.php\n```\n\n### Configuration\n\n```php\n\u003c?php\nreturn [\n    'locale' =\u003e 'zh_CN',\n    'fallback_locale' =\u003e 'en',\n    'path' =\u003e BASE_PATH . '/storage/languages',\n];\n```\n\n### Exception handler\n\n```php\n\u003c?php\nreturn [\n    'handler' =\u003e [\n        'http' =\u003e [\n            \\Hyperf\\Validation\\ValidationExceptionHandler::class,\n        ],\n    ],\n];\n```\n\n### Validation middleware\n\n```php\n\u003c?php\nreturn [\n    'http' =\u003e [\n        \\Hyperf\\Validation\\Middleware\\ValidationMiddleware::class,\n    ],\n];\n```\n\n## Usage\n\n### Generate form request\n\nCommand:\n```\nphp bin/hyperf.php gen:request FooRequest\n```\n\nUsage:\n```php\nclass IndexController\n{\n    public function foo(FooRequest $request)\n    {\n        $request-\u003einput('foo');\n    }\n    \n    public function bar(RequestInterface $request)\n    {\n        $factory = $this-\u003econtainer-\u003eget(\\Hyperf\\Validation\\Contract\\ValidatorFactoryInterface::class);\n\n        $factory-\u003eextend('foo', function ($attribute, $value, $parameters, $validator) {\n            return $value == 'foo';\n        });\n\n        $factory-\u003ereplacer('foo', function ($message, $attribute, $rule, $parameters) {\n            return str_replace(':foo', $attribute, $message);\n        });\n\n        $validator = $factory-\u003emake(\n            $request-\u003eall(),\n            [\n                'name' =\u003e 'required|foo',\n            ],\n            [\n                'name.foo' =\u003e ':foo is not foo',\n            ]\n        );\n\n        if (!$validator-\u003epasses()) {\n             $validator-\u003eerrors();\n        }\n    }\n}\n```\n","funding_links":["https://opencollective.com/hyperf","https://hyperf.wiki/#/zh-cn/donate"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperf%2Fvalidation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyperf%2Fvalidation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperf%2Fvalidation/lists"}