{"id":14966461,"url":"https://github.com/yiisoft/validator","last_synced_at":"2025-05-15T13:05:34.395Z","repository":{"id":37550461,"uuid":"181050526","full_name":"yiisoft/validator","owner":"yiisoft","description":"Yii validator library","archived":false,"fork":false,"pushed_at":"2025-05-07T12:04:12.000Z","size":2554,"stargazers_count":114,"open_issues_count":41,"forks_count":40,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-05-11T18:33:12.181Z","etag":null,"topics":["hacktoberfest","validation","validator","yii3"],"latest_commit_sha":null,"homepage":"https://www.yiiframework.com/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yiisoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"open_collective":"yiisoft","github":["yiisoft"]}},"created_at":"2019-04-12T17:05:23.000Z","updated_at":"2025-05-07T14:04:47.000Z","dependencies_parsed_at":"2023-12-25T17:27:12.876Z","dependency_job_id":"b95ee3cc-d928-40e2-960e-fc697024363f","html_url":"https://github.com/yiisoft/validator","commit_stats":{"total_commits":551,"total_committers":44,"mean_commits":"12.522727272727273","dds":0.7096188747731398,"last_synced_commit":"22d6572a1b4902333a167fe41b23eaf2735a0e52"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fvalidator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fvalidator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fvalidator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Fvalidator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yiisoft","download_url":"https://codeload.github.com/yiisoft/validator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254346624,"owners_count":22055808,"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":["hacktoberfest","validation","validator","yii3"],"created_at":"2024-09-24T13:36:25.071Z","updated_at":"2025-05-15T13:05:34.372Z","avatar_url":"https://github.com/yiisoft.png","language":"PHP","funding_links":["https://opencollective.com/yiisoft","https://github.com/sponsors/yiisoft"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/yiisoft\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://yiisoft.github.io/docs/images/yii_logo.svg\" height=\"100px\" alt=\"Yii\"\u003e\n    \u003c/a\u003e\n    \u003ch1 align=\"center\"\u003eYii Validator\u003c/h1\u003e\n    \u003cbr\u003e\n\u003c/p\u003e\n\n[![Latest Stable Version](https://poser.pugx.org/yiisoft/validator/v)](https://packagist.org/packages/yiisoft/validator)\n[![Total Downloads](https://poser.pugx.org/yiisoft/validator/downloads)](https://packagist.org/packages/yiisoft/validator)\n[![Build status](https://github.com/yiisoft/validator/actions/workflows/build.yml/badge.svg)](https://github.com/yiisoft/validator/actions/workflows/build.yml)\n[![Code Coverage](https://codecov.io/gh/yiisoft/validator/branch/master/graph/badge.svg)](https://codecov.io/gh/yiisoft/validator)\n[![Mutation testing badge](https://img.shields.io/endpoint?style=flat\u0026url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyiisoft%2Fvalidator%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/validator/master)\n[![type-coverage](https://shepherd.dev/github/yiisoft/validator/coverage.svg)](https://shepherd.dev/github/yiisoft/validator)\n[![static analysis](https://github.com/yiisoft/validator/workflows/static%20analysis/badge.svg)](https://github.com/yiisoft/validator/actions?query=workflow%3A%22static+analysis%22)\n[![psalm-level](https://shepherd.dev/github/yiisoft/validator/level.svg)](https://shepherd.dev/github/yiisoft/validator)\n\nThis package provides data validation capabilities.\n\n## Features\n\n- Validates any data: arrays, objects, scalar values, etc.\n- Supports custom data sets.\n- Handles nested data structures (one-to-one and one-to-many).\n- Can read validation rules from PHP 8 attributes.\n- Error message formatting and translation.\n- Attribute names translation.\n- Conditional validation:\n  - Skip validation of \"empty\" value with possibility to configure \"empty\" condition.\n  - Skip further validation if an error occurred for the same property.\n  - Skip validation depending on a condition.\n- Possibility to use context in rule handler.\n- Common rules bundled.\n- Supports DI container for creating custom rule handlers with extra dependencies.\n- Exporting rules options for using in the frontend.\n\n## Requirements\n\n- PHP 8.1 or higher.\n- `mbstring` PHP extension.\n\n## Installation\n\nThe package could be installed with [Composer](https://getcomposer.org):\n\n```shell\ncomposer require yiisoft/validator\n```\n\n## General usage\n\nValidator allows to check data in any format. For example, when data is an object:\n\n```php\nuse Yiisoft\\Validator\\Rule\\FilledAtLeast;\nuse Yiisoft\\Validator\\Rule\\Email;\nuse Yiisoft\\Validator\\Rule\\Length;\nuse Yiisoft\\Validator\\Rule\\Number;\nuse Yiisoft\\Validator\\Rule\\Required;\nuse Yiisoft\\Validator\\Validator;\n\n#[FilledAtLeast(['email', 'phone'])]\nfinal class Person\n{\n    public function __construct(\n        #[Required]\n        #[Length(min: 2)]\n        public ?string $name = null,\n\n        #[Number(min: 21)]\n        public ?int $age = null,\n\n        #[Email]\n        public ?string $email = null,\n\n        public ?string $phone = null,\n    ) {\n    }\n}\n\n$person = new Person(\n    name: 'John', \n    age: 17, \n    email: 'john@example.com',\n    phone: null\n);\n\n$result = (new Validator())-\u003evalidate($person);\n```\n\nThe validation result is an object that allows to check whether validation was successful:\n\n```php\n$result-\u003eisValid();\n```\n\nIt also contains errors occurred during validation:\n\n```php\n$result-\u003egetErrorMessages();\n```\n\n## Documentation\n\n- Guide: [English](docs/guide/en/README.md), [Português - Brasil](docs/guide/pt-BR/README.md)\n- [Internals](docs/internals.md)\n\nIf you need help or have a question, the [Yii Forum](https://forum.yiiframework.com/c/yii-3-0/63) is a good place for that.\nYou may also check out other [Yii Community Resources](https://www.yiiframework.com/community).\n\n## License\n\nThe Yii Validator is free software. It is released under the terms of the BSD License.\nPlease see [`LICENSE`](./LICENSE.md) for more information.\n\nMaintained by [Yii Software](https://www.yiiframework.com/).\n\n## Support the project\n\n[![Open Collective](https://img.shields.io/badge/Open%20Collective-sponsor-7eadf1?logo=open%20collective\u0026logoColor=7eadf1\u0026labelColor=555555)](https://opencollective.com/yiisoft)\n\n## Follow updates\n\n[![Official website](https://img.shields.io/badge/Powered_by-Yii_Framework-green.svg?style=flat)](https://www.yiiframework.com/)\n[![Twitter](https://img.shields.io/badge/twitter-follow-1DA1F2?logo=twitter\u0026logoColor=1DA1F2\u0026labelColor=555555?style=flat)](https://twitter.com/yiiframework)\n[![Telegram](https://img.shields.io/badge/telegram-join-1DA1F2?style=flat\u0026logo=telegram)](https://t.me/yii3en)\n[![Facebook](https://img.shields.io/badge/facebook-join-1DA1F2?style=flat\u0026logo=facebook\u0026logoColor=ffffff)](https://www.facebook.com/groups/yiitalk)\n[![Slack](https://img.shields.io/badge/slack-join-1DA1F2?style=flat\u0026logo=slack)](https://yiiframework.com/go/slack)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiisoft%2Fvalidator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyiisoft%2Fvalidator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiisoft%2Fvalidator/lists"}