attributes-php/validation
最新稳定版本:v0.9.0
Composer 安装命令:
composer require attributes-php/validation
包简介
The PHP Pydantic validation library which supports data validation via type-hinting
README 文档
README
Attributes Validation is the Pydantic validation library for PHP which allows you to validate data via type hints
Features
- Validates data via type-hinting
- Converts raw dictionaries into classes
- Support for custom validation rules
Requirements
- PHP 8.1+
- Attributes-PHP/options
- respect/validation
We aim to support versions that haven't reached their end-of-life.
How it works?
<?php use Attributes\Validation\Validator; use Respect\Validation\Rules as Rules; class Person { #[Rules\Min(0)] public float|int $age; public ?DateTime $birthday; } $rawData = [ 'age' => '30', 'birthday' => '1994-01-01T09:00:00+00:00', ]; $validator = new Validator(); $person = $validator->validate($rawData, new Person); var_dump($person->age); // int(30) var_dump($person->birthday); // object(DateTime) { ["date"] => string(26) "1994-01-01 09:00:00.000000", (...) }
Installation
composer require attributes-php/validation
Attributes Validation was created by André Gil and is open-sourced software licensed under the MIT license.
统计信息
- 总下载量: 351
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-12