{"id":21916376,"url":"https://github.com/dsheiko/validate","last_synced_at":"2025-06-25T17:08:42.574Z","repository":{"id":56972853,"uuid":"113566931","full_name":"dsheiko/validate","owner":"dsheiko","description":"Extendable PHP validation library for testing complex types against a contract","archived":false,"fork":false,"pushed_at":"2018-02-07T17:06:33.000Z","size":47,"stargazers_count":15,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-19T08:15:48.607Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dsheiko.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-08T11:22:16.000Z","updated_at":"2024-12-25T03:51:08.000Z","dependencies_parsed_at":"2022-08-21T10:20:19.930Z","dependency_job_id":null,"html_url":"https://github.com/dsheiko/validate","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/dsheiko/validate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsheiko%2Fvalidate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsheiko%2Fvalidate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsheiko%2Fvalidate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsheiko%2Fvalidate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dsheiko","download_url":"https://codeload.github.com/dsheiko/validate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsheiko%2Fvalidate/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261917437,"owners_count":23229917,"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-28T19:17:42.848Z","updated_at":"2025-06-25T17:08:42.549Z","avatar_url":"https://github.com/dsheiko.png","language":"PHP","funding_links":[],"categories":["Programming Languages"],"sub_categories":["PHP"],"readme":"# Dsheiko\\Validate\n\n[![Latest Stable Version](https://poser.pugx.org/dsheiko/validate/v/stable)](https://packagist.org/packages/dsheiko/validate)\n[![Total Downloads](https://poser.pugx.org/dsheiko/validate/downloads)](https://packagist.org/packages/dsheiko/validate)\n[![License](https://poser.pugx.org/dsheiko/validate/license)](https://packagist.org/packages/dsheiko/validate)\n[![Build Status](https://travis-ci.org/dsheiko/validate.png)](https://travis-ci.org/dsheiko/validate)\n\nExtendable validation library for testing primitive and complex types (including key-value arrays) against a contract\n\n* [Installation](#installation)\n* [Usage](#usage)\n\n## Installation\n\nRequire as a composer dependency:\n\n``` bash\ncomposer require \"dsheiko/validate\"\n```\n\n## Highlights\n- Validators are dead simple to extend\n- It's really easy to validate precondition/postcondition contracts\n- Validator assertions are directly accessible\n- Validation of nested arrays\n\n\n## Usage\n\n- [Basic Usage](./wiki/basic-usage.md)\n- [Provided Validators](./wiki/validators.md)\n- [Validator Chain](./wiki/validator-chain.md)\n- [Validation by Contract](./wiki/validation-by-contract.md)\n- [Map Validation](./wiki/map-validation.md)\n- [Custom Validators](./wiki/validator-interface.md)\n\n## Examples\n\n\n### Design by Contract\n```php\n\u003c?php\nuse \\Dsheiko\\Validate;\n\nfunction login($email, $password)\n{\n    Validate::contract([\n      \"email\" =\u003e [ $email, \"IsEmailAddress\" ],\n      \"password\" =\u003e [ $password, [ \"IsString\"=\u003e [ \"minLength\" =\u003e 6, \"maxLength\" =\u003e 32, \"notEmpty\" =\u003e true ] ] ],\n    ]);\n    // do login\n}\n```\n\nmay throw\n\n- `Dsheiko\\Validate\\IsString\\Exception`\n- `Dsheiko\\Validate\\IsString\\minLength\\Exception`\n- `Dsheiko\\Validate\\IsString\\maxLength\\Exception`\n- `Dsheiko\\Validate\\IsEmail\\Exception`\n\nwith a message like\n\n- `Parameter \"email\" validation failed: \"jon#snow.i..\" is not a valid email address`\n- `Parameter \"password\" validation failed: \"123\" is too short; must be more than 6 chars`\n\n### Map Validation\n```php\n\u003c?php\n\n$params = [\n  \"email\" =\u003e \"jon#snow.io\",\n  \"password\" =\u003e \"******\",\n];\n\nValidate::map($params, [\n    \"email\" =\u003e [\"mandatory\", \"IsEmailAddress\"],\n    \"password\" =\u003e [\"mandatory\", \"IsString\" =\u003e [\"minLength\" =\u003e 6, \"maxLength\" =\u003e 128]],\n    \"rememberMe\" =\u003e [\"optional\", \"IsBool\" ],\n]);\n\n```\n\nException messages look like:\n\n- `Property \"email\" validation failed: \"jon#snow.i..\" is not a valid email address`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsheiko%2Fvalidate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdsheiko%2Fvalidate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsheiko%2Fvalidate/lists"}