{"id":34866576,"url":"https://github.com/yulia633/php-oop-project-lvl1","last_synced_at":"2026-04-27T02:31:43.374Z","repository":{"id":45907964,"uuid":"510832134","full_name":"yulia633/php-oop-project-lvl1","owner":"yulia633","description":"The training project by Hexlet ","archived":false,"fork":false,"pushed_at":"2022-08-07T17:24:08.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-27T07:11:47.451Z","etag":null,"topics":["oop-php","php","phpunit","studing-for-fun","validator"],"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/yulia633.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2022-07-05T17:24:35.000Z","updated_at":"2022-07-27T19:04:37.000Z","dependencies_parsed_at":"2022-08-27T22:42:33.558Z","dependency_job_id":null,"html_url":"https://github.com/yulia633/php-oop-project-lvl1","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yulia633/php-oop-project-lvl1","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yulia633%2Fphp-oop-project-lvl1","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yulia633%2Fphp-oop-project-lvl1/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yulia633%2Fphp-oop-project-lvl1/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yulia633%2Fphp-oop-project-lvl1/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yulia633","download_url":"https://codeload.github.com/yulia633/php-oop-project-lvl1/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yulia633%2Fphp-oop-project-lvl1/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32320236,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["oop-php","php","phpunit","studing-for-fun","validator"],"created_at":"2025-12-25T22:34:33.037Z","updated_at":"2026-04-27T02:31:43.363Z","avatar_url":"https://github.com/yulia633.png","language":"PHP","readme":"### Hexlet tests and linter status:\n[![Actions Status](https://github.com/yulia633/php-oop-project-lvl1/workflows/hexlet-check/badge.svg)](https://github.com/yulia633/php-oop-project-lvl1/actions)\n[![Github Actions Status](https://github.com/yulia633/php-oop-project-lvl1/workflows/PHP%20CI/badge.svg)](https://github.com/yulia633/php-oop-project-lvl1/actions)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/9aa567c0ff8910595dd4/test_coverage)](https://codeclimate.com/github/yulia633/php-oop-project-lvl1/test_coverage)\n[![Maintainability](https://api.codeclimate.com/v1/badges/9aa567c0ff8910595dd4/maintainability)](https://codeclimate.com/github/yulia633/php-oop-project-lvl1/maintainability)\n\n### О коде\n\nВалидация строк, чисел и массивов в соответствии с предопределенными или пользовательскими правилами.\n\n#### Проверка строк\n\n```php\n\n\u003c?php\n\n$v = new \\Hexlet\\Validator\\Validator();\n\n$schema = $v-\u003estring();\n// Каждый вызов возвращает новую схему,\n// так как у нас может быть любое количество независимых проверок\n$schema2 = $v-\u003estring(); // $schema != $schema2\n\n$schema-\u003eisValid(''); // true\n\n// Null валидное значение для всех валидаторов\n// если не задан required\n$schema-\u003eisValid(null); // true\n\n$schema-\u003eisValid('what does the fox say'); // true\n\n$schema-\u003erequired();\n\n$schema2-\u003eisValid(''); // По прежнему валидно, это другая схема\n$schema-\u003eisValid(null); // А тут не валидно\n$schema-\u003eisValid(''); // И тут тоже\n\n$schema-\u003eisValid('hexlet'); // true\n\n$schema-\u003econtains('what')-\u003eisValid('what does the fox say'); // true\n$schema-\u003econtains('whatthe')-\u003eisValid('what does the fox say'); // false\n\n// Если один валидатор вызывался несколько раз\n// то последний имеет приоритет (перетирает предыдущий)\n$v-\u003estring()-\u003eminLength(10)-\u003eminLength(5)-\u003eisValid('Hexlet'); // true\n\n```\n\n#### Проверка чисел\n\n```php\n\n\u003c?php\n\n$v = new \\Hexlet\\Validator\\Validator();\n\n$schema = $v-\u003enumber();\n\n$schema-\u003eisValid(null); // true\n\n$schema-\u003erequired();\n\n$schema-\u003eisValid(null); // false\n\n// Достаточно работать с типом Integer\n$schema-\u003eisValid(7); // true\n\n$schema-\u003epositive()-\u003eisValid(10); // true\n\n$schema-\u003erange(-5, 5);\n\n$schema-\u003eisValid(-3); // false\n$schema-\u003eisValid(5); // true\n\n```\n\n#### Проверка массивов\n\n```php\n\n\u003c?php\n\n$v = new \\Hexlet\\Validator\\Validator();\n\n$schema = $v-\u003earray();\n\n$schema-\u003eisValid(null); // true\n\n$schema = $schema-\u003erequired();\n\n$schema-\u003eisValid([]); // true\n$schema-\u003eisValid(['hexlet']); // true\n\n$schema-\u003esizeof(2); // true\n\n$schema-\u003eisValid(['hexlet']); // false\n$schema-\u003eisValid(['hexlet', 'code-basics']); // true\n\n// Позволяет описывать валидацию для ключей массива\n$schema-\u003eshape([\n    'name' =\u003e $v-\u003estring()-\u003erequired(),\n    'age' =\u003e $v-\u003enumber()-\u003epositive(),\n]);\n\n$schema-\u003eisValid(['name' =\u003e 'kolya', 'age' =\u003e 100]); // true\n$schema-\u003eisValid(['name' =\u003e 'maya', 'age' =\u003e null]); // true\n$schema-\u003eisValid(['name' =\u003e '', 'age' =\u003e null]); // false\n$schema-\u003eisValid(['name' =\u003e 'ada', 'age' =\u003e -5]); // false\n\n```\n\n#### Добавление собственных валидаторов\n\n```php\n\u003c?php\n\n$v = new \\Hexlet\\Validator\\Validator();\n\n$fn = fn($value, $start) =\u003e str_starts_with($value, $start);\n// Метод добавления новых валидаторов\n// addValidator($type, $name, $fn)\n$v-\u003eaddValidator('string', 'startWith', $fn);\n\n// Новые валидаторы вызываются через метод test\n$schema = $v-\u003estring()-\u003etest('startWith', 'H');\n$schema-\u003eisValid('exlet'); // false\n$schema-\u003eisValid('Hexlet'); // true\n\n$fn = fn($value, $min) =\u003e $value \u003e= $min;\n$v-\u003eaddValidator('number', 'min', $fn);\n\n$schema = $v-\u003enumber()-\u003etest('min', 5);\n$schema-\u003eisValid(4); // false\n$schema-\u003eisValid(6); // true\n\n// Если валидатора нет, то бросаем исключение\n$v-\u003eaddValidator('wrong-name', 'startWith', $fn); // boom!\n\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyulia633%2Fphp-oop-project-lvl1","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyulia633%2Fphp-oop-project-lvl1","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyulia633%2Fphp-oop-project-lvl1/lists"}