{"id":21541563,"url":"https://github.com/mesak/laravel-opis-validator","last_synced_at":"2026-07-01T02:31:09.875Z","repository":{"id":57749626,"uuid":"524705297","full_name":"mesak/laravel-opis-validator","owner":"mesak","description":"Laravel FormRequest With Opis Validator","archived":false,"fork":false,"pushed_at":"2022-08-16T09:04:52.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-23T18:50:18.019Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mesak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-14T15:13:14.000Z","updated_at":"2024-07-07T18:06:59.000Z","dependencies_parsed_at":"2022-08-28T08:41:42.499Z","dependency_job_id":null,"html_url":"https://github.com/mesak/laravel-opis-validator","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/mesak/laravel-opis-validator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesak%2Flaravel-opis-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesak%2Flaravel-opis-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesak%2Flaravel-opis-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesak%2Flaravel-opis-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mesak","download_url":"https://codeload.github.com/mesak/laravel-opis-validator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesak%2Flaravel-opis-validator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34990845,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-01T02:00:05.325Z","response_time":130,"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":[],"created_at":"2024-11-24T05:06:54.903Z","updated_at":"2026-07-01T02:31:09.853Z","avatar_url":"https://github.com/mesak.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Opis JSON Schema\n\nLaravel FormRequest With Opis JSON Schema Validator\n\nUse [Opis JSON Schema](https://github.com/opis/json-schema) to validate your laravel form requests.\n\n# installation\n\n```bash\ncomposer require mesak/laravel-opis-validator\n```\n\nOr you could directly reference it into your `composer.json` file as a dependency\n  \n```json\n{\n    \"require\": {\n        \"mesak/laravel-opis-validator\": \"^1.0.0\"\n    }\n}\n```\n## Example\n\n### Requests\n```php\n\u003c?php\n\nnamespace App\\Http\\Requests;\n\nuse Mesak\\LaravelOpisValidator\\JsonSchemaRequest;\n\nclass JsonSchema extends JsonSchemaRequest\n{\n    protected $extendValidatorMessage = true;\n\n    /**\n     * Get the validation rules that apply to the request.\n     *\n     * @return array\n     */\n    public function rules()\n    {\n        return [\n            '$schema' =\u003e \"http://json-schema.org/draft-07/schema#\",\n            \"type\" =\u003e \"object\",\n            \"title\" =\u003e \"Base Preference\",\n            \"description\" =\u003e \"Base Preference Setting\",\n            \"properties\" =\u003e [\n                \"limit\" =\u003e [\n                    \"type\" =\u003e \"integer\",\n                    \"minimum\" =\u003e 5,\n                    \"maximum\" =\u003e 15,\n                    \"title\" =\u003e \"limit\",\n                    \"attrs\" =\u003e [\n                        \"placeholder\" =\u003e \"limit (limit)\"\n                    ]\n                ],\n                \"page\" =\u003e [\n                    \"type\" =\u003e \"object\",\n                    \"title\" =\u003e \"Page\",\n                    \"attrs\" =\u003e [\n                        \"placeholder\" =\u003e \"Page ( Page )\"\n                    ],\n                    \"properties\" =\u003e [\n                        \"limit\" =\u003e [\n                            \"type\" =\u003e \"integer\"\n                        ]\n                    ]\n                ]\n            ],\n            \"additionalProperties\" =\u003e false,\n            \"required\" =\u003e [\n                \"limit\",\n                \"page\"\n            ]\n        ];\n    }\n    protected function prepareForValidation()\n    {\n        //clear urlencoded data from request \n        //input integer is not allowed in json schema\n        $intance = $this-\u003egetValidatorInstance();\n        foreach ($intance-\u003egetRules() as $key =\u003e $rule) {\n            $inputValue = $this-\u003einput($key);\n            if ($rule == 'integer' \u0026\u0026 preg_match('/\\d+/', $inputValue)) {\n                $this-\u003emerge([\n                $key =\u003e intval($inputValue),\n                ]);\n            }\n        }\n        $intance-\u003esetData($this-\u003eall());\n    }\n}\n```\n\n\n### Controller\n```php\n\nuse App\\Http\\Requests\\JsonSchema as JsonSchemaRequest;\n\n    public function update(JsonSchemaRequest $request)\n    {\n        dd($request-\u003evalidated());\n    }\n```\n\nuse postman to test your request.\n\n```\ncurl --location --request POST 'http://localhost/test/update' \\\n--header 'Content-Type: application/json' \\\n--header 'Accept: application/json' \\\n--data-raw '{\n    \"limit\" :10,\n    \"page\": {\n        \"limit\" : 10\n    }\n}'\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmesak%2Flaravel-opis-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmesak%2Flaravel-opis-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmesak%2Flaravel-opis-validator/lists"}