codepoetry / request-validation
PHP应用程序的REST负载验证。
1.0.5
2023-09-09 11:29 UTC
Requires
- php: ^8.2
This package is auto-updated.
Last update: 2024-09-09 15:08:38 UTC
README
PHP应用程序的REST负载验证
描述
codepoetry/request-validation
是一个PHP库,它为PHP应用程序提供验证REST API负载的功能。它帮助您确保传入的数据符合指定的规则和约束,使您的应用程序更加健壮和安全。
安装
您可以通过 Composer 安装此包。
composer require codepoetry/request-validation
要求
- PHP >= 8.2
使用
以下是一个使用此包的基本示例:在 app/Http/Requests
中创建 ExampleRequest.php
文件。
<?php namespace App\Http\Requests; use Codepoetry\RequestValidation\RequestAbstract; class ExampleRequest extends RequestAbstract { /** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize(): bool { return true; } /** * Get the validation rules that apply to the request. * * @return array */ public function rules(): array { return [ "email" => "require" ]; } /** * Get custom messages for validator errors. * * @return array */ public function messages(): array { return [ "email.unique" => trans('validation.email_unique'), ]; } }
文档
有关详细文档和示例,请参阅 官方文档。
许可证
此包是专有软件。有关许可信息,请参阅 LICENSE 文件。
作者
- Manab Roy - codepoetryindia@gmail.com - Manab的网站
贡献
欢迎贡献!请参阅我们的 贡献指南 了解更多详情。
问题
如果您发现任何问题或有问题,请随时在 问题跟踪器 中提交问题。
变更日志
有关最近更改的信息,请参阅 CHANGELOG.md 文件。
鸣谢
- 特别感谢 贡献者,他们帮助改进了此项目。