solophp/validator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

solophp/validator

最新稳定版本:v3.1.0

Composer 安装命令:

composer require solophp/validator

包简介

PHP Data Validator

README 文档

README

Lightweight PHP validation library with custom rules and structured errors.

Latest Version on Packagist PHP Version License

Features

  • Built-in Rules — Required, email, phone, uuid, min, max, length, numeric, date, and more
  • Custom Rules — Extend validation with your own rules via callbacks
  • Structured Errors — Machine-readable error objects with rule names and parameters
  • Parameterized Rules — Define rules like min:8, max:100, in:a,b,c
  • Phone Validation — International phone validation via libphonenumber
  • Lightweight — Minimal dependencies, PSR-4 compliant

Installation

composer require solophp/validator

Quick Example

use Solo\Validator\Validator;

$validator = new Validator();

$data = [
    'email' => 'user@example.com',
    'username' => 'john_doe',
    'age' => 25,
];

$rules = [
    'email' => 'required|email',
    'username' => 'required|min:3|max:20',
    'age' => 'integer|min_value:18',
];

$errors = $validator->validate($data, $rules);

if ($validator->fails()) {
    print_r($validator->errors());
    // [
    //     'field' => [
    //         ['rule' => 'email'],
    //         ['rule' => 'min', 'params' => ['3']],
    //     ],
    // ]
} else {
    echo "Validation passed!";
}

Documentation

Full Documentation

Requirements

  • PHP 8.1+

License

MIT License. See LICENSE for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固