{"id":22656873,"url":"https://github.com/libreworks/caridea-validate","last_synced_at":"2025-07-03T21:33:41.739Z","repository":{"id":35197590,"uuid":"39456026","full_name":"libreworks/caridea-validate","owner":"libreworks","description":":fried_shrimp: Caridea is a miniscule PHP application library. This is a shrimpy validation library.","archived":false,"fork":false,"pushed_at":"2018-01-28T20:11:31.000Z","size":92,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-03T21:47:34.625Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/libreworks.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}},"created_at":"2015-07-21T16:11:59.000Z","updated_at":"2016-11-17T19:50:57.000Z","dependencies_parsed_at":"2022-09-15T11:40:32.780Z","dependency_job_id":null,"html_url":"https://github.com/libreworks/caridea-validate","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libreworks%2Fcaridea-validate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libreworks%2Fcaridea-validate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libreworks%2Fcaridea-validate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libreworks%2Fcaridea-validate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/libreworks","download_url":"https://codeload.github.com/libreworks/caridea-validate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246156419,"owners_count":20732397,"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-12-09T10:16:46.016Z","updated_at":"2025-03-29T08:11:19.606Z","avatar_url":"https://github.com/libreworks.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# caridea-validate\nCaridea is a miniscule PHP application library. This shrimpy fellow is what you'd use when you just want some helping hands and not a full-blown framework.\n\n![](http://libreworks.com/caridea-100.png)\n\nThis is its validation library.\n\nIt supports [LIVR rules](https://github.com/koorchik/LIVR) with some exceptions. See the Compliance → _LIVR_ section below.\n\n[![Packagist](https://img.shields.io/packagist/v/caridea/validate.svg)](https://packagist.org/packages/caridea/validate)\n[![Build Status](https://travis-ci.org/libreworks/caridea-validate.svg)](https://travis-ci.org/libreworks/caridea-validate)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/libreworks/caridea-validate/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/libreworks/caridea-validate/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/libreworks/caridea-validate/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/libreworks/caridea-validate/?branch=master)\n[![Documentation Status](http://readthedocs.org/projects/caridea-validate/badge/?version=latest)](http://caridea-validate.readthedocs.io/en/latest/?badge=latest)\n\n## Installation\n\nYou can install this library using Composer:\n\n```console\n$ composer require caridea/validate\n```\n\n* The master branch (version 3.x) of this project requires PHP 7.1 and has no dependencies.\n* Version 2.x of this project requires PHP 7.0 and has no dependencies.\n* Version 1.x of this project requires PHP 5.5 and has no dependencies.\n\n## Documentation\n\n* Head over to [Read the Docs](http://caridea-validate.readthedocs.io/en/latest/)\n\n## Compliance\n\nReleases of this library will conform to [Semantic Versioning](http://semver.org).\n\nOur code is intended to comply with [PSR-1](http://www.php-fig.org/psr/psr-1/), [PSR-2](http://www.php-fig.org/psr/psr-2/), and [PSR-4](http://www.php-fig.org/psr/psr-4/). If you find any issues related to standards compliance, please send a pull request!\n\n### LIVR\n\nWe fully support the JSON rule format as defined by the LIVR spec. However, we do not support the v0.4 style declaration for the `one_of` and `list_of` rules.\n\nFor the most part, we support all rules and their return codes as defined by version 2.0 of the specification with some notable exceptions. We did not implement the following rules:\n\n* `trim` – This is part of filtering, not validation.\n* `to_lc` – This is part of filtering, not validation.\n* `to_uc` – This is part of filtering, not validation.\n* `remove` – This is part of filtering, not validation.\n* `leave_only` – This is part of filtering, not validation.\n* `default` – This is part of filtering, not validation.\n* `or` – This is experimental.\n\nWe now support alias definitions!\n\nWe did add an extra validator: `timezone`! It gives the error `WRONG_TIMEZONE` if the string provided isn't a valid timezone identifier.\n\n## Examples\n\nTo create a validator from a rule set, you can pass the definitions to the\nbuilder, or you can use the builder procedurally.\n\n```javascript\n// rules.json\n{\n    \"name\": \"required\",\n    \"email\": [\"required\", \"email\"],\n    \"drinks\": { \"one_of\": [[\"coffee\", \"tea\"]] },\n    \"phone\": {\"max_length\": 10},\n}\n```\n```php\n$registry = new \\Caridea\\Filter\\Registry();\n$builder = $registry-\u003ebuilder();\n$ruleset = json_decode(file_get_contents('rules.json'));\n$validator = $builder-\u003ebuild($ruleset);\n```\n```php\n$registry = new \\Caridea\\Filter\\Registry();\n$builder = $registry-\u003ebuilder();\n$validator = $builder-\u003efield('name', 'required')\n    -\u003efield('email', 'required', 'email')\n    -\u003efield('drinks', ['one_of' =\u003e [['coffee', 'tea']]])\n    -\u003efield('phone', ['max_length' =\u003e 10])\n    -\u003ebuild();\n```\n\nYou can either inspect the validation results, or throw an exception containing any errors.\n\n```php\n$input = [\n    'foo' =\u003e 'bar',\n    'abc' =\u003e '123',\n];\n$result = $validator-\u003evalidate($input);\n// or\n$validator-\u003eassert($input);\n```\n\nYou can register your own custom rules in the `Registry`.\n\n```php\n$registry = new \\Caridea\\Validate\\Registry();\n$registry-\u003eregister([\n    'credit_card' =\u003e ['MyCustomRules', 'getCreditCard'], // a static method\n]);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibreworks%2Fcaridea-validate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibreworks%2Fcaridea-validate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibreworks%2Fcaridea-validate/lists"}