定制 ir0ny1/validator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

ir0ny1/validator

Composer 安装命令:

composer require ir0ny1/validator

包简介

PHP Validator inspired by Illuminate Framework

README 文档

README

Build Status Code Climate Test Coverage #Validation Helper Written By Dave Richer ##For Course: CST8257 Web Application Development ###Release Date: October 17th 2015 ###Version: 1.0.0

####Current Valid rules:

Rule Description
required Field is required
sameAs:property Field is same has property
minLength:number Field is at least number characters long
maxLength:number Field is not longer then number characters long
equalTo:value Field Equals Value
phoneNumber Field is in (NNN) NNN-NNNN format
postalCode Field is in A0A0A0 or A0A 0A0 format
emailAddress Field is a valid email address
complexPassword Field is a complex password with 1 capital, 1 lowercase, 1 numeric, 1 special character and a minimum of six characters long

####Example:

$rules = [
    "name"  =>  "required:min:6"
];

$data = [
    "name"  =>  "Dave"
];

// Set the data and rules when creating the object
$val = new Validator($data, $rules);
// Or after..
$val->setData($data);
$val->setRules($rules);
// Or chain
$val->setData($data)->setRules($rules);

// Either validate with the validate method
$val->validate();
// Or validate by invoking the object itself
$val();

if (!val->valid()) {
    echo $val->validationMessageFor("name");
}

####Would Produce Name must be at least six characters long

$val->validationSummary();

Will return an array of all validation messages

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-24