{"id":22496993,"url":"https://github.com/morebec/validator","last_synced_at":"2025-03-27T21:25:35.876Z","repository":{"id":57019777,"uuid":"235106998","full_name":"Morebec/Validator","owner":"Morebec","description":"The Validator component provides tools to validate data","archived":false,"fork":false,"pushed_at":"2020-03-07T10:34:18.000Z","size":63,"stargazers_count":1,"open_issues_count":13,"forks_count":1,"subscribers_count":3,"default_branch":"dev","last_synced_at":"2024-04-25T15:21:12.615Z","etag":null,"topics":["orkestra","php","validation","validator"],"latest_commit_sha":null,"homepage":null,"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/Morebec.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-20T13:24:46.000Z","updated_at":"2020-03-06T11:27:09.000Z","dependencies_parsed_at":"2022-08-22T20:31:12.056Z","dependency_job_id":null,"html_url":"https://github.com/Morebec/Validator","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morebec%2FValidator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morebec%2FValidator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morebec%2FValidator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morebec%2FValidator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Morebec","download_url":"https://codeload.github.com/Morebec/Validator/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245925720,"owners_count":20694950,"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":["orkestra","php","validation","validator"],"created_at":"2024-12-06T20:15:21.397Z","updated_at":"2025-03-27T21:25:35.837Z","avatar_url":"https://github.com/Morebec.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Validator\n[![Build Status](https://travis-ci.com/Morebec/Validator.svg?branch=master)](https://travis-ci.com/Morebec/Validator)\n\nThe Validator component makes data validation easy. Its primary use is intended to ensure that the data of forms, Rest API and configuration files is in an appropriate and valid state.\n\nA lot of validation libraries rely on an exception mechanism. This forces developers to check multiple related data fields one by one. This component instead uses validation errors that can be used for multiple pieces of data together. This is useful for example to return all errors for a given form at once.\n\n## Installation\n```bash\ncomposer require morebec/validator\n```\n\n## Usage\n\n```php\n\nuse Morebec\\Validator\\Rule as Assert;\nuse Morebec\\Validator\\Validator;\n\n\n// Validate a single rule for a given field\nValidator::validate($form['email_address'], new Assert\\One(\n    new Assert\\IsString('The email address field was expected to be a string')\n));\n\n// Validate Multiple Rules for a given field\nValidator::validate($form['email_address'], new Assert\\All([\n    new Assert\\IsString('The email address field was expected to be a string'),\n    new Assert\\NotBlank('The email address field was expected not to be blank'),\n    new Assert\\IsEmail('The email address field was expected to be a valid email address'),\n]));\n\n\n// Ensure At least one rule is valid\nValidator::validate($form['email_address'], new Assert\\AtLeastOne([\n    new Assert\\IsString('The email address field was expected to be a string'),\n    new Assert\\NotBlank('The email address field was expected not to be blank'),\n    new Assert\\IsEmail('The email address field was expected to be a valid email address'),\n]));\n```\n\n## Running Tests\n```bash\nphp vendor/bin/phpunit --bootstrap vendor/autoload.php tests\n```\n\n## Contributing\nThank you for your interest :)  \nTo contribute, please read the `CONTRIBUTING.md` guidelines.\n\n## Getting help\nTo get help, open a new issue on this repository.  \nFor Morebec team members, please use the appropriate internal channels.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorebec%2Fvalidator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorebec%2Fvalidator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorebec%2Fvalidator/lists"}