{"id":19031978,"url":"https://github.com/johnnymast/redbox-validator","last_synced_at":"2026-01-27T01:31:11.163Z","repository":{"id":147835768,"uuid":"618520730","full_name":"johnnymast/redbox-validator","owner":"johnnymast","description":"A validation package based on Laravel's validation package.","archived":false,"fork":false,"pushed_at":"2024-11-06T16:43:39.000Z","size":172,"stargazers_count":0,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-09T06:16:27.592Z","etag":null,"topics":["custom-rules","nodependence","php","psr-12","validation"],"latest_commit_sha":null,"homepage":"https://johnnymast.io","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/johnnymast.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"johnnymast"}},"created_at":"2023-03-24T16:42:06.000Z","updated_at":"2023-03-30T19:17:36.000Z","dependencies_parsed_at":"2024-12-21T22:00:26.847Z","dependency_job_id":null,"html_url":"https://github.com/johnnymast/redbox-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/johnnymast%2Fredbox-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnnymast%2Fredbox-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnnymast%2Fredbox-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnnymast%2Fredbox-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnnymast","download_url":"https://codeload.github.com/johnnymast/redbox-validator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232151180,"owners_count":18479688,"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":["custom-rules","nodependence","php","psr-12","validation"],"created_at":"2024-11-08T21:25:56.196Z","updated_at":"2026-01-27T01:31:11.157Z","avatar_url":"https://github.com/johnnymast.png","language":"PHP","funding_links":["https://github.com/sponsors/johnnymast"],"categories":[],"sub_categories":[],"readme":"# Redbox-valiation\n\nRedbox-validation is a simple to use validation class. The implementation is based on Laravel's (but no a rewrite of)\nvalidation package but has no external when used in your project.\n\n[![Packagist](https://img.shields.io/packagist/v/redbox/validation.svg)](https://packagist.org/packages/redbox/validation)\n[![Unit Tests](https://github.com/johnnymast/redbox-validation/actions/workflows/Tests.yml/badge.svg)](https://github.com/johnnymast/redbox-validation/actions/workflows/Tests.yml)\n[![PhpCS](https://github.com/johnnymast/redbox-validation/actions/workflows/Phpcs.yaml/badge.svg)](https://github.com/johnnymast/redbox-validation/actions/workflows/Phpcs.yaml)\n[![PhpCS](https://raw.githubusercontent.com/johnnymast/redbox-validation/master/badges/coverage-badge.svg)](https://github.com/johnnymast/redbox-validation/actions/workflows/pest-coverage.yaml)\n\n## Installation\n\n```bash\n$ composer require redbox/validation\n```\n\n## Usage\n\nThe package is flexible to use with an easy syntax.\n\n## Basic Usage\n```php \nuse Redbox\\Validation\\Validator;\n\n$validator = new Validator([\n    'foo' =\u003e 'The quick brown fox jumps over the lazy dog'\n]);\n\n$data = $validator-\u003evalidate([\n    'food' =\u003e 'string'\n]);\n\n/**\n * Validator::passes() is also\n * available.\n */\nif ($validator-\u003efails()) {\n    /**\n     * Handle errors use $validator-\u003eerrors()\n     * to get the errors.\n     */\n}\n```\n\n## Using closures\n\nYou can use your own closures to add custom rules \n\n```php\n\nuse Redbox\\Validation\\ValidationContext;\nuse Redbox\\Validation\\Validator;\n\n$validator = new Validator([\n    'foo' =\u003e 'The quick brown fox jumps over the lazy dog'\n]);\n\n$data = $validator-\u003evalidate([\n    /**\n     * This will validate field 'foo' equals 'baz' in this case it will not so\n     * the validation will fail and an error will be set for field 'foo'.\n     */\n    'foo' =\u003e function (ValidationContext $context): bool {\n\n        return ($context-\u003ekeyExists() \u0026\u0026  $context-\u003egetValue() === 'baz')\n            or $context-\u003eaddError(\"Field {$context-\u003egetKey()} does not equal 'baz'.\");\n    }\n]);\n\n/**\n * Validator::passes() is also\n * available.\n */\nif ($validator-\u003efails()) {\n    /**\n     * Handle errors use $validator-\u003eerrors()\n     * to get the errors.\n     */\n    print_r($validator-\u003eerrors());\n}\n```\n\n## Available Rules\n\nThe following validation rules are available with this package.\n\n| Type    | Alias | Description                                         |\n|---------|-------|-----------------------------------------------------|\n| string  | N/A   | The field under validation must be of type string.  |\n| boolean | bool  | The field under validation must be of type boolean. |\n| integer | int   | The field under validation must be of type integer. |\n\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2023 Johnny Mast\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnnymast%2Fredbox-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnnymast%2Fredbox-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnnymast%2Fredbox-validator/lists"}