承接 mithridatem/validation 相关项目开发

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

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

mithridatem/validation

最新稳定版本:v0.1.3

Composer 安装命令:

composer require mithridatem/validation

包简介

Attribute-based validation components

README 文档

README

Librairie de validation basee sur les attributs PHP 8.2+. Elle permet d'annoter vos entites avec des contraintes et de les verifier via la classe Validator.

Installation

composer require mithridatem/validation

Utilisation

use Mithridatem\Validation\Validator;
use Mithridatem\Validation\Attributes\NotBlank;
use Mithridatem\Validation\Attributes\Length;

class Utilisateur
{
    #[NotBlank]
    #[Length(min: 3, max: 50)]
    private string $prenom;
}

$validator = new Validator();
$validator->validate(new Utilisateur());

En cas d'echec, le Validator leve une Mithridatem\Validation\Exception\ValidationException. Interceptez cette exception pour afficher ou journaliser le message.

Contraintes disponibles

  • NotBlank : interdit les valeurs nulles ou les chaines vides
  • Length : impose une longueur minimale et/ou maximale
  • Email : valide une adresse electronique avec FILTER_VALIDATE_EMAIL
  • Pattern : impose un pattern regex à une string
  • Negative : impose une valeur négative à un entier
  • NegativeOrZero : impose une valeur négative ou égale à zéro à un entier
  • Positive : impose une valeur positive à un entier
  • PositiveOrZero : impose une valeur positive ou égale à zéro à un entier

Developpement

composer install
composer test

Licence

Le projet est distribue sous licence MIT. Voir LICENSE.

统计信息

  • 总下载量: 78
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-19