{"id":21874533,"url":"https://github.com/smoren/validator-php","last_synced_at":"2025-04-15T01:24:06.518Z","repository":{"id":144796551,"uuid":"617215527","full_name":"Smoren/validator-php","owner":"Smoren","description":"Responsible validation tools with fluent interface","archived":false,"fork":false,"pushed_at":"2024-12-18T21:21:03.000Z","size":164,"stargazers_count":6,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T13:21:13.552Z","etag":null,"topics":["fluentvalidation","php","php-library","validation","validation-library","validator"],"latest_commit_sha":null,"homepage":"","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/Smoren.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":"2023-03-21T23:25:18.000Z","updated_at":"2024-12-18T21:21:07.000Z","dependencies_parsed_at":"2024-12-18T22:24:53.589Z","dependency_job_id":"7f2c340a-2f70-4e03-a1fd-31e68adf4902","html_url":"https://github.com/Smoren/validator-php","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smoren%2Fvalidator-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smoren%2Fvalidator-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smoren%2Fvalidator-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Smoren%2Fvalidator-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Smoren","download_url":"https://codeload.github.com/Smoren/validator-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248986882,"owners_count":21194137,"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":["fluentvalidation","php","php-library","validation","validation-library","validator"],"created_at":"2024-11-28T07:12:39.451Z","updated_at":"2025-04-15T01:24:06.513Z","avatar_url":"https://github.com/Smoren.png","language":"PHP","readme":"# PHP Validation Tools\n\n![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/smoren/validator)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Smoren/validator-php/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Smoren/validator-php/?branch=master)\n[![Coverage Status](https://coveralls.io/repos/github/Smoren/validator-php/badge.svg?branch=master)](https://coveralls.io/github/Smoren/validator-php?branch=master)\n![Build and test](https://github.com/Smoren/validator-php/actions/workflows/test_master.yml/badge.svg)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n## How to install to your project\n```\ncomposer require smoren/validator\n```\n\n## Usage\n\n```php\nuse Smoren\\Validator\\Factories\\Value;\nuse Smoren\\Validator\\Exceptions\\ValidationError;\n\n$rule = Value::container()\n    -\u003earray()\n    -\u003ehasAttribute('id', Value::integer()-\u003epositive())\n    -\u003ehasAttribute('probability', Value::float()-\u003ebetween(0, 1))\n    -\u003ehasAttribute('vectors', Value::container()-\u003earray()-\u003eallValuesAre(\n        Value::container()\n            -\u003earray()\n            -\u003elengthIs(Value::integer()-\u003eequal(2))\n            -\u003eallValuesAre(Value::integer())\n    ));\n\n$validInput = [\n    'id' =\u003e 13,\n    'probability' =\u003e 0.92,\n    'vectors' =\u003e [[1, 2], [3, 4], [5, 6]],\n];\n\ntry {\n    $rule-\u003evalidate($validInput);\n} catch (ValidationError $e) {\n    // Input is valid so this block is unreachable.\n}\n\n$invalidInput = [\n    'id' =\u003e '13',\n    'probability' =\u003e 1.92,\n    'vectors' =\u003e [[1, 2.1], [3, 4], [5, 6]],\n];\n\ntry {\n    $rule-\u003evalidate($invalidInput);\n} catch (ValidationError $e) {\n    // Input is invalid so we catch the exception.\n    print_r($e-\u003egetViolatedRestrictions());\n    /*\n    [\n        ['attribute_is', [\n            'attribute' =\u003e 'id',\n            'rule' =\u003e 'integer',\n            'violated_restrictions' =\u003e [\n                ['integer', []]\n            ]\n        ]],\n        ['attribute_is', [\n            'attribute' =\u003e 'probability',\n            'rule' =\u003e 'float',\n            'violated_restrictions' =\u003e [\n                ['between', [\n                    'start' =\u003e 0,\n                    'end' =\u003e 1\n                ]]\n            ]\n        ]],\n        ['attribute_is', [\n            'attribute' =\u003e 'vectors',\n            'rule' =\u003e 'container',\n            'violated_restrictions' =\u003e [\n                ['all_values_are', [\n                    'rule' =\u003e 'container',\n                    'violated_restrictions' =\u003e [\n                        ['all_values_are', [\n                            'rule' =\u003e 'integer',\n                            'violated_restrictions' =\u003e [\n                                ['integer', []]\n                            ]\n                        ]]\n                    ]\n                ]]\n            ]\n        ]]\n    ]\n    */\n}\n\n```\n\n## Unit testing\n```\ncomposer install\ncomposer test-init\ncomposer test\n```\n\n## Standards\n\nPHP Validator Tools conforms to the following standards:\n\n* PSR-1 — [Basic coding standard](https://www.php-fig.org/psr/psr-1/)\n* PSR-4 — [Autoloader](https://www.php-fig.org/psr/psr-4/)\n* PSR-12 — [Extended coding style guide](https://www.php-fig.org/psr/psr-12/)\n\n\n## License\n\nPHP Validation Tools is licensed under the MIT License.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmoren%2Fvalidator-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmoren%2Fvalidator-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmoren%2Fvalidator-php/lists"}