承接 pingle/validator 相关项目开发

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

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

pingle/validator

Composer 安装命令:

composer require pingle/validator

包简介

Server side user input validation library

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License

You can install Validator either via package download from github or via composer install. I encourage you to do the latter:

{ 
  "require": {
    "pingle/validator": "dev-master"
  }
} 

This is a small PHP class that makes it easy to validate forms in your project specially larger forms. Pingle Validator class provide the validation for the user input on the server side.

Basic usage

namespace Pingle/Validator;

//initialize the class
$val = new Validator();

/*** use POST as the source ***/
$val->addSource($_POST);

/*** add a form field rule ***/
/*** addRule('name', 'type', required, min, max, trim, regex)***/
$val->addRule('name', 'string', true, 5, 255, true)
    ->addRule('email', 'email', true, 1, 255, true)
    ->addRule('website', 'url', false, 1, 255, true)
    ->addRule('age', 'numeric', true, 1, 100, true)
    ->addRule('salary', 'float', false, 1, 99999999, true)
    ->addRule('date', 'regex', true, 10, 10, true,"#^(((?:0?[1-9]|1[012])|(?:0?[1-9]|[12][0-9]|3[01])|([a-zA-Z]+))([.,]?[-.\\\/\s]))?(((?:0?[1-9]|1[012])|(?:0?[1-9]|[12][0-9]|3[01])|([a-zA-Z]+))([.,]?[-.\\\/\s]))?((?:20|19)[0-9]{2})$#");
/*** run the validation rules ***/
$val->run();
/*** if there are errors show them ***/
if(sizeof($val->errors) > 0)
{
    print_r($val->errors);
}
else
{
    $_POST=$val->sanitized;
}

Validation Methods

  1. string
  2. email
  3. url
  4. numeric
  5. float
  6. regex
  7. ipv4
  8. ipv6
  9. bool

统计信息

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

GitHub 信息

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

其他信息

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