定制 openlss/lib-validate 二次开发

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

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

openlss/lib-validate

Composer 安装命令:

composer require openlss/lib-validate

包简介

Validation helper with a shorthand syntax.

README 文档

README

Validation helper with a shorthand syntax.

Usage

use \LSS\Validate;

$data = array('myparam'=>'valid string');

try {
	Validate::prime($data);
	Validate::go('myparam')->not('blank')->max(20)->is('alnum');
	Validate::paint();
} catch(Exception $e){
	echo $e;
}

Types

All these types will evaluate to true IF:

  • blank '' === true
  • empty empty() === true
  • null is_null($var)
  • ip var is IPv4 octect format
  • mac True if var is in mac address format (loose check for chars)
  • domain True if var is a domain name (loose check for chars)
  • num True if var is all numeric
  • dec True if the var is numeric with a decimal point
  • float Same as dec
  • alpha True if all characters are alpha-numeric
  • al Same as alpha
  • alu Same as alpha but with underscores (_)
  • als True if var is alphanumeric with spaces
  • alnums Alias to als
  • en Alias to als
  • email True if chars are valid for an email address
  • sha1 True if var is a sha1 hash
  • md5 True of var is a md5 hash

Reference

(void) Validate::prime($data)

Prep validate with an array of data usualy from post()

(object) Validate::go($var)

Starts a validation object for the given param

(object) Validate::_get()

Returns the current instance

(object) Validate::error($err)

Add error message to buffer This is generally used internally

(object) Validate::setVar($var)

Sets the var to operate on This is generally used internally

(string) Validate::get()

Retrieves the current variable This is generally used internally

(object) Validate::min($min)

Checks that the current var is at minimum $min long

(object) Validate::max($max)

Checks that the current var is at maximum $max long

(object) Validate::not($type)

Checks that the current var is not given $type

(object) Validate::is($type)

Checks that the current var is given #type

(bool) Validate::paint()

If there are any errors in the buffer an exception will be raised Otherwise TRUE is returned

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: LGPL-3.0
  • 更新时间: 2013-03-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固