承接 attributes-php/validation 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

Latest Version Software License

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

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-12