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

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

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

particle/validator

最新稳定版本:v2.3.6

Composer 安装命令:

composer require particle/validator

包简介

Flexible and highly usable validation library with no dependencies.

README 文档

README

Travis-CI Packagist Packagist downloads Scrutinizer Scrutinizer

Particle\Validator is a very small validation library, with the easiest and most usable API we could possibly create.

Install

To easily include Particle\Validator into your project, install it via composer using the command line:

composer require particle/validator

Small usage example

use Particle\Validator\Validator;

$v = new Validator;

$v->required('user.first_name')->lengthBetween(2, 50)->alpha();
$v->required('user.last_name')->lengthBetween(2, 50)->alpha();
$v->required('newsletter')->bool();

$result = $v->validate([
    'user' => [
        'first_name' => 'John',
        'last_name' => 'D',
    ],
    'newsletter' => true,
]);

$result->isValid(); // bool(false).
$result->getMessages();
/**
 * array(1) {
 *     ["user.last_name"]=> array(1) {
 *         ["Length::TOO_SHORT"]=> string(53) "last_name is too short and must be 2 characters long."
 *     }
 * }
 */

Functional features

  • Validate an array of data
  • Get an array of error messages
  • Overwrite the default error messages on rules, or error messages on specific values
  • Get the validated values of an array
  • Validate different contexts (insert, update, etc.) inheriting validations of the default context
  • A large set of default validation rules
  • Ability to extend the validator to add your own custom rules

Non functional features

  • Easy to write (IDE auto-completion for easy development)
  • Easy to read (improves peer review)
  • Ability to separate controller and view logic
  • Fully documented: validator.particle-php.com
  • Fully tested: Scrutinizer
  • Zero dependencies

===

Find more information and advanced usage examples at validator.particle-php.com

统计信息

  • 总下载量: 1.59M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 260
  • 点击次数: 2
  • 依赖项目数: 16
  • 推荐数: 0

GitHub 信息

  • Stars: 251
  • Watchers: 11
  • Forks: 41
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2015-03-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固