{"id":18289926,"url":"https://github.com/mehrshaddarzi/wp-rest-api-validate","last_synced_at":"2026-04-15T23:31:54.902Z","repository":{"id":156468345,"uuid":"633033262","full_name":"mehrshaddarzi/wp-rest-api-validate","owner":"mehrshaddarzi","description":"Laravel Validation for WordPress REST API Plugin","archived":false,"fork":false,"pushed_at":"2023-04-26T16:59:03.000Z","size":1454,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-21T12:27:52.425Z","etag":null,"topics":["laravel-validation","php","rest-api","wordpress","wordpress-development","wordpress-plugin","wordpress-rest-api"],"latest_commit_sha":null,"homepage":"","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/mehrshaddarzi.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-26T16:27:30.000Z","updated_at":"2023-09-28T07:42:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"e9de3eb3-be7a-43e4-a5a0-1bc2d68314ed","html_url":"https://github.com/mehrshaddarzi/wp-rest-api-validate","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/mehrshaddarzi/wp-rest-api-validate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mehrshaddarzi%2Fwp-rest-api-validate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mehrshaddarzi%2Fwp-rest-api-validate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mehrshaddarzi%2Fwp-rest-api-validate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mehrshaddarzi%2Fwp-rest-api-validate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mehrshaddarzi","download_url":"https://codeload.github.com/mehrshaddarzi/wp-rest-api-validate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mehrshaddarzi%2Fwp-rest-api-validate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278717664,"owners_count":26033578,"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","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"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":["laravel-validation","php","rest-api","wordpress","wordpress-development","wordpress-plugin","wordpress-rest-api"],"created_at":"2024-11-05T14:08:49.935Z","updated_at":"2025-10-07T04:11:45.946Z","avatar_url":"https://github.com/mehrshaddarzi.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Validation for WordPress REST API Plugin\n\n![Packagist](https://img.shields.io/github/license/mehrshaddarzi/wp-trait)\n\nProfessional validation argument for WordPress REST API\n\n## Table of Contents\n\n* [Installation](#installation)\n* [How to use in register rest route](#how-to-use-in-register_rest_route)\n* [List of WordPress Hooks](#list-of-wordpress-hooks)\n* [Contributing](#contributing)\n* [License](#license)\n\n## Installation\n\n[Download zip file](https://github.com/mehrshaddarzi/wp-rest-api-validate/releases/download/v1.0.0/wp-rest-api-validate.zip) and install plugin in your WordPress site.\n\n### How to use in register_rest_route\n\nYou Can add `validate` parameter in `register_rest_route` function:\n\n```php\nadd_action('rest_api_init', 'register_routes');\nfunction register_routes()\n{\n\n    register_rest_route(\n        'v1',\n        'book/add',\n        array(\n            'methods' =\u003e \\WP_REST_Server::CREATABLE,\n            'callback' =\u003e 'callback_function_name',\n            'permission_callback' =\u003e '__return_true',\n            'args' =\u003e [\n                'isbn' =\u003e [\n                    'title' =\u003e __('Book ISBN'),\n                    'validate' =\u003e ['required', 'min:5']\n                ],\n                'image' =\u003e [\n                    'title' =\u003e __('screenshot'),\n                    'validate' =\u003e ['file', 'mimes:jpg,png']\n                ],\n                'meta' =\u003e [\n                    'title' =\u003e __('meta'),\n                    'validate' =\u003e 'required|array|min:3'\n                ],\n                'author' =\u003e [\n                    'title' =\u003e __('Author Book'),\n                    'validate' =\u003e ['required', function ($attribute, $value, $fail) {\n                        if (strlen($value) \u003c 10) {\n                            $fail(\"Show Error in closure-based Validation\");\n                        }\n                    }]\n                ]\n            ]\n        )\n    );\n}\n```\n\n### List of Laravel Validation\n\nAll laravel validation Rules are available in this plugin:\n\nhttps://laravel.com/docs/10.x/validation#available-validation-rules\n\n\n### List of WordPress Hooks\n\n#### Use custom parameter key in your code\n```php\napply_filters('wp_rest_api_validate_args_key', 'validate');\n```\n\n#### Use custom language (default is WordPress locale)\n```php\napply_filters('wp_rest_api_validate_locale', get_locale());\n```\n\n#### Change validation language dir\n```php\napply_filters('wp_rest_api_validate_lang_dir', dirname(__FILE__) . '/lang');\n```\n\n#### Pre Validation Start\n\nuse for disable or add custom condition by request:\n\n```php\napply_filters('wp_rest_api_validate_pre', \n    null, \n    \\WP_REST_Response $response, \n    \\WP_REST_Request $request, \n    $handler\n);\n```\n\n## Contributing\n\n- [Mehrshad Darzi](https://www.linkedin.com/in/mehrshaddarzi/)\n\nWe appreciate you taking the initiative to contribute to this project.\nContributing isn’t limited to just code. We encourage you to contribute in the way that best fits your abilities, by\nwriting tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our\ndocumentation.\n\n## License\n\nThe `wp-rest-api-validate` is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmehrshaddarzi%2Fwp-rest-api-validate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmehrshaddarzi%2Fwp-rest-api-validate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmehrshaddarzi%2Fwp-rest-api-validate/lists"}