{"id":20132314,"url":"https://github.com/mysiar/array-validator","last_synced_at":"2026-05-12T06:38:21.407Z","repository":{"id":57022869,"uuid":"240056354","full_name":"mysiar/array-validator","owner":"mysiar","description":"Array Validator","archived":false,"fork":false,"pushed_at":"2020-05-23T14:12:43.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-13T09:09:38.766Z","etag":null,"topics":[],"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/mysiar.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-12T16:10:00.000Z","updated_at":"2020-05-23T14:12:46.000Z","dependencies_parsed_at":"2022-08-23T13:50:19.709Z","dependency_job_id":null,"html_url":"https://github.com/mysiar/array-validator","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mysiar%2Farray-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mysiar%2Farray-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mysiar%2Farray-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mysiar%2Farray-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mysiar","download_url":"https://codeload.github.com/mysiar/array-validator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241577094,"owners_count":19984941,"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":[],"created_at":"2024-11-13T20:53:11.278Z","updated_at":"2026-05-12T06:38:16.387Z","avatar_url":"https://github.com/mysiar.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mysiar/array-validator\n\n[![Build Status](https://travis-ci.org/mysiar/array-validator.svg?branch=master)](https://travis-ci.org/mysiar/array-validator)\n\n# Usage\n\n* example\n\n\n    ```php\n    \n    use Mysiar\\ArrayValidator\\Validator;\n    use Symfony\\Component\\Validator\\Constraints\\Callback;\n    use Symfony\\Component\\Validator\\Constraints\\Choice;\n    use Symfony\\Component\\Validator\\Constraints\\Date;\n    use Symfony\\Component\\Validator\\Constraints\\Email;\n    use Symfony\\Component\\Validator\\Constraints\\NotBlank;\n    use Symfony\\Component\\Validator\\Constraints\\Positive;\n    use Symfony\\Component\\Validator\\Constraints\\PositiveOrZero;\n    use Symfony\\Component\\Validator\\Context\\ExecutionContextInterface;\n    \n    $validator = new Validator();\n    \n    $validator-\u003eaddArrayConstraint(new Callback(function($record, ExecutionContextInterface $context) {\n        if (count($record) !== 15) {\n            $context-\u003eaddViolation(sprintf('The array must contain %s columns', 15));\n        }\n    }));\n    \n    $validator-\u003eaddArrayElementConstraint(0, new Positive());\n    $validator-\u003eaddArrayElementConstraint(1, new NotBlank());\n    $validator-\u003eaddArrayElementConstraint(2, new NotBlank());\n    $validator-\u003eaddArrayElementConstraint(3, new NotBlank());\n    $validator-\u003eaddArrayElementConstraint(4, new NotBlank());\n    $validator-\u003eaddArrayElementConstraint(5, new Date());\n    $validator-\u003eaddArrayElementConstraint(6, new Positive());\n    $validator-\u003eaddArrayElementConstraint(7, new NotBlank());\n    $validator-\u003eaddArrayElementConstraint(8, new Email());\n    $validator-\u003eaddArrayElementConstraint(9, new Date());\n    $validator-\u003eaddArrayElementConstraint(10, new Positive());\n    $validator-\u003eaddArrayElementConstraint(12, new Choice([0, 1]));\n    $validator-\u003eaddArrayElementConstraint(13, new PositiveOrZero());\n    $validator-\u003eaddArrayElementConstraint(14, new PositiveOrZero());\n    \n    ```\n\n\n* notice: in case you use function `fgetcsv` to read csv file line by line to validate Choice of values in the array element you may need to use\n    ```\n    $validator-\u003eaddArrayElementConstraint(2, new Choice([\"0\", \"1\"]));\n    ```\n    instead\n    ```\n    $validator-\u003eaddArrayElementConstraint(2, new Choice([0, 1]));\n    ```\n\n### Credits\nCreated by [Piotr Synowiec](https://github.com/mysiar), inspired by [deblan/csv-validator](https://gitnet.fr/deblan/csv-validator)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmysiar%2Farray-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmysiar%2Farray-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmysiar%2Farray-validator/lists"}