{"id":26418671,"url":"https://github.com/devknown/request-validator","last_synced_at":"2025-10-17T07:24:00.427Z","repository":{"id":62551428,"uuid":"509863798","full_name":"devknown/request-validator","owner":"devknown","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-03T15:58:34.000Z","size":46,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-17T13:46:42.592Z","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":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devknown.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,"governance":null}},"created_at":"2022-07-02T21:19:30.000Z","updated_at":"2024-09-18T14:36:51.000Z","dependencies_parsed_at":"2023-12-03T16:40:09.044Z","dependency_job_id":null,"html_url":"https://github.com/devknown/request-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/devknown%2Frequest-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devknown%2Frequest-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devknown%2Frequest-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devknown%2Frequest-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devknown","download_url":"https://codeload.github.com/devknown/request-validator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244141583,"owners_count":20404835,"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":"2025-03-18T01:54:20.160Z","updated_at":"2025-10-07T19:15:43.307Z","avatar_url":"https://github.com/devknown.png","language":"PHP","readme":"# PHP Request Validator\n\nMake your apps validation easily (inspired by Laravel Validation)\n\nthe original project: \u003ca href=\"https://github.com/progsmile/request-validator/graphs/contributors\"\u003eprogsmile/request-validator\u003c/a\u003e. this version adds Mysqli Adapter.\n\n---\n\nPage Index:\n- [Quick Start](#quick-start)\n- [Contributing](#contributing)\n- [Testing](#testing)\n- [License](#license)\n\nSuggested Links:\n- [Installation](/docs/installation.md)\n- [Feature Guide](/docs/feature-guide.md)\n- Rules\n    - [Existing Rules](/docs/rules.md)\n    - [Data Provider](/docs/rules-database.md)\n    - [Customization](/docs/rules-customization.md)\n    - [Formatting Message](/docs/formatting-message.md)\n- [Integrations](/docs/integrations.md)\n\n----\n\n\u003ca name=\"quick-start\"\u003e\u003c/a\u003e\n## Quick start :rocket:\n```php\n\u003c?php\n\n$rules = [\n    # firstname and lastname must exists\n    # they should be alphanumeric\n    # atleast 2 characters\n    'firstname, lastname' =\u003e 'required|alpha|min:2',\n\n    # max until 18 characters only\n    'lastname'            =\u003e 'max:18',\n\n    # must be an email format\n    # must be unique under 'users' table\n    'email'               =\u003e 'email|unique:users',\n\n    # must be numeric\n    # must exists under 'users' table\n    'id'                  =\u003e 'numeric|exists:users',\n    'age'                 =\u003e 'min:16|numeric',\n    'info[country]'       =\u003e 'required|alpha',\n\n    # roll[0] or roll[1] values must be in the middle 1 to 100\n    'roll[0], roll[1]'    =\u003e 'numeric|between:1, 100',\n\n    # the format must be 'm-Y.d H:i'\n    'date'                =\u003e 'dateFormat:(m-Y.d H:i)',\n\n    # it must be an image format under $_FILES global variable\n    'profileImg'          =\u003e 'image',\n\n    # the provided phone number should follow the format\n    # correct: +38(123)456-12-34\n    # wrong: +38(123)56-123-56\n    # wrong: +39(123)456-12-34\n    'phoneMask'           =\u003e 'phoneMask:(+38(###)###-##-##)',\n    'randNum'             =\u003e 'between:1, 10|numeric',\n\n    # the value must be an IP Format\n    'ip'                  =\u003e 'ip',\n    'password'            =\u003e 'required|min:6',\n\n    # the value from a key 'password' must be equal to 'password_repeat' value\n    'password_repeat'     =\u003e 'same:password',\n\n    # it must be a json format\n    'json'                =\u003e 'json',\n    'site'                =\u003e 'url',\n\n    # cash10 or cash25 must only have these\n    # 1 or 2 or 5 or 10 or 20 or 50\n    'cash10, cash25'      =\u003e 'in:1, 2, 5, 10, 20, 50',\n\n    # the value must not have 13 or 18 or 3 or 4\n    'elevatorFloor'       =\u003e 'notIn:13, 18, 3, 4',\n];\n\n$customMessage = [\n   'info[country].alpha' =\u003e 'Only letters please',\n   'email.required'      =\u003e 'Field :field: is required',\n   'email.email'         =\u003e 'Email has bad format',\n   'email.unique'        =\u003e 'This email :value: is not unique',\n   'elevatorFloor.notIn' =\u003e 'Oops',\n];\n\n$v = V::make($_POST, $rules, $customMessage);\n\n# for specific field\n# you can use below code.\n$v-\u003elastname-\u003epasses();\n$v-\u003elastname-\u003efails();\n\n# if you're required to check everything\n# and there must no failing validation\n$v-\u003epasses();\n$v-\u003efails();\n\n# get first error message\n$v-\u003efirst();\n\n# get first error for `firstname`\n$v-\u003efirst('lastname');\n$v-\u003efirstname-\u003efirst();\n\n# return first error message from each field\n$v-\u003efirsts();\n\n# get all messages (with param for concrete field)\n$v-\u003emessages();\n$v-\u003emessages('password');\n\n# get all `password` messages\n$v-\u003epassword-\u003emessages();\n\n# get 2d array with fields and messages\n$v-\u003eraw();\n\n# to append a message\n$v-\u003eadd('someField', 'Something is wrong with this');\n```\n\n\u003ca name=\"contributing\"\u003e\u003c/a\u003e\n## Contributing :octocat:\n\nDear contributors , the project is just started and it is not stable yet, we love to have your fork requests.\n\n\n\u003ca name=\"testing\"\u003e\u003c/a\u003e\n## Testing\n\nThis testing suite uses [Travis CI](https://travis-ci.org/) for each run. Every commit pushed to this repository will queue a build into the continuous integration service and will run all tests to ensure that everything is going well and the project is stable.\n\nThe testing suite can be run on your own machine. The main dependency is [PHPUnit](https://github.com/sebastianbergmann/phpunit) which can be installed using [Composer](http://getcomposer.org):\n\n```sh\n# run this command from project root\n$ composer install --dev --prefer-source\n```\n\nA MySQL database is also required for several tests. Follow these instructions to create the database:\n\n```sh\necho 'create database valid charset=utf8mb4 collate=utf8mb4_unicode_ci;' | mysql -u root\ncat tests/dist/schema.sql | mysql valid -u root\n```\n\nFor these tests we use the user `root` without a password. You may need to change this in `tests/TestHelper.php` file.\n\nOnce the database is created, run the tests on a terminal:\n\n```sh\nvendor/bin/phpunit --configuration phpunit.xml --coverage-text\n```\n\nFor additional information see [PHPUnit The Command-Line Test Runner](http://phpunit.de/manual/current/en/textui.html).\n\n\u003ca name=\"license\"\u003e\u003c/a\u003e\n## License\n\nPHP Request Validator is open-sourced software licensed under the [GNU GPL](LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevknown%2Frequest-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevknown%2Frequest-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevknown%2Frequest-validator/lists"}