Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Donate
Please sign in before you donate.
Scan WeChat QR to Pay
Cancel
Complete
Prompt
Switch to Alipay.
OK
Cancel
1 Star 0 Fork 0

HPlus/validate

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (1)
Tags (7)
master
v2.1.0
v1.0.6
v1.0.5
v1.0.4
v1.0.3
v1.0.2
v1.0.1
master
Branches (1)
Tags (7)
master
v2.1.0
v1.0.6
v1.0.5
v1.0.4
v1.0.3
v1.0.2
v1.0.1
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (1)
Tags (7)
master
v2.1.0
v1.0.6
v1.0.5
v1.0.4
v1.0.3
v1.0.2
v1.0.1
validate
/
src
/
ValidateRule.php
validate
/
src
/
ValidateRule.php
ValidateRule.php 7.64 KB
Copy Edit Raw Blame History
bbhkxd authored 2020年09月23日 23:23 +08:00 . init
<?php
namespace HPlus\Validate;
namespace HPlus\Validate;
/**
* Class ValidateRule
* @package think\validate
* @method ValidateRule confirm(mixed $field, string $msg = '') static 验证是否和某个字段的值一致
* @method ValidateRule different(mixed $field, string $msg = '') static 验证是否和某个字段的值是否不同
* @method ValidateRule egt(mixed $value, string $msg = '') static 验证是否大于等于某个值
* @method ValidateRule gt(mixed $value, string $msg = '') static 验证是否大于某个值
* @method ValidateRule elt(mixed $value, string $msg = '') static 验证是否小于等于某个值
* @method ValidateRule lt(mixed $value, string $msg = '') static 验证是否小于某个值
* @method ValidateRule eg(mixed $value, string $msg = '') static 验证是否等于某个值
* @method ValidateRule in(mixed $values, string $msg = '') static 验证是否在范围内
* @method ValidateRule notIn(mixed $values, string $msg = '') static 验证是否不在某个范围
* @method ValidateRule between(mixed $values, string $msg = '') static 验证是否在某个区间
* @method ValidateRule notBetween(mixed $values, string $msg = '') static 验证是否不在某个区间
* @method ValidateRule length(mixed $length, string $msg = '') static 验证数据长度
* @method ValidateRule max(mixed $max, string $msg = '') static 验证数据最大长度
* @method ValidateRule min(mixed $min, string $msg = '') static 验证数据最小长度
* @method ValidateRule after(mixed $date, string $msg = '') static 验证日期
* @method ValidateRule before(mixed $date, string $msg = '') static 验证日期
* @method ValidateRule expire(mixed $dates, string $msg = '') static 验证有效期
* @method ValidateRule allowIp(mixed $ip, string $msg = '') static 验证IP许可
* @method ValidateRule denyIp(mixed $ip, string $msg = '') static 验证IP禁用
* @method ValidateRule regex(mixed $rule, string $msg = '') static 使用正则验证数据
* @method ValidateRule token(mixed $token, string $msg = '') static 验证表单令牌
* @method ValidateRule is(mixed $rule = null, string $msg = '') static 验证字段值是否为有效格式
* @method ValidateRule isRequire(mixed $rule = null, string $msg = '') static 验证字段必须
* @method ValidateRule isNumber(mixed $rule = null, string $msg = '') static 验证字段值是否为数字
* @method ValidateRule isArray(mixed $rule = null, string $msg = '') static 验证字段值是否为数组
* @method ValidateRule isInteger(mixed $rule = null, string $msg = '') static 验证字段值是否为整形
* @method ValidateRule isFloat(mixed $rule = null, string $msg = '') static 验证字段值是否为浮点数
* @method ValidateRule isMobile(mixed $rule = null, string $msg = '') static 验证字段值是否为手机
* @method ValidateRule isIdCard(mixed $rule = null, string $msg = '') static 验证字段值是否为身份证号码
* @method ValidateRule isChs(mixed $rule = null, string $msg = '') static 验证字段值是否为中文
* @method ValidateRule isChsDash(mixed $rule = null, string $msg = '') static 验证字段值是否为中文字母及下划线
* @method ValidateRule isChsAlpha(mixed $rule = null, string $msg = '') static 验证字段值是否为中文和字母
* @method ValidateRule isChsAlphaNum(mixed $rule = null, string $msg = '') static 验证字段值是否为中文字母和数字
* @method ValidateRule isDate(mixed $rule = null, string $msg = '') static 验证字段值是否为有效格式
* @method ValidateRule isBool(mixed $rule = null, string $msg = '') static 验证字段值是否为布尔值
* @method ValidateRule isAlpha(mixed $rule = null, string $msg = '') static 验证字段值是否为字母
* @method ValidateRule isAlphaDash(mixed $rule = null, string $msg = '') static 验证字段值是否为字母和下划线
* @method ValidateRule isAlphaNum(mixed $rule = null, string $msg = '') static 验证字段值是否为字母和数字
* @method ValidateRule isAccepted(mixed $rule = null, string $msg = '') static 验证字段值是否为yes, on, 或是 1
* @method ValidateRule isEmail(mixed $rule = null, string $msg = '') static 验证字段值是否为有效邮箱格式
* @method ValidateRule isUrl(mixed $rule = null, string $msg = '') static 验证字段值是否为有效URL地址
* @method ValidateRule activeUrl(mixed $rule = null, string $msg = '') static 验证是否为合格的域名或者IP
* @method ValidateRule ip(mixed $rule = null, string $msg = '') static 验证是否有效IP
* @method ValidateRule fileExt(mixed $ext, string $msg = '') static 验证文件后缀
* @method ValidateRule fileMime(mixed $mime, string $msg = '') static 验证文件类型
* @method ValidateRule fileSize(mixed $size, string $msg = '') static 验证文件大小
* @method ValidateRule image(mixed $rule, string $msg = '') static 验证图像文件
* @method ValidateRule method(mixed $method, string $msg = '') static 验证请求类型
* @method ValidateRule dateFormat(mixed $format, string $msg = '') static 验证时间和日期是否符合指定格式
* @method ValidateRule unique(mixed $rule, string $msg = '') static 验证是否唯一
* @method ValidateRule behavior(mixed $rule, string $msg = '') static 使用行为类验证
* @method ValidateRule filter(mixed $rule, string $msg = '') static 使用filter_var方式验证
* @method ValidateRule requireIf(mixed $rule, string $msg = '') static 验证某个字段等于某个值的时候必须
* @method ValidateRule requireCallback(mixed $rule, string $msg = '') static 通过回调方法验证某个字段是否必须
* @method ValidateRule requireWith(mixed $rule, string $msg = '') static 验证某个字段有值的情况下必须
* @method ValidateRule must(mixed $rule = null, string $msg = '') static 必须验证
*/
class ValidateRule
{
// 验证字段的名称
protected $title;
// 当前验证规则
protected $rule = [];
// 验证提示信息
protected $message = [];
/**
* 添加验证因子
* @access protected
* @param string $name 验证名称
* @param mixed $rule 验证规则
* @param string $msg 提示信息
* @return $this
*/
protected function addItem($name, $rule = null, $msg = '')
{
if ($rule || 0 === $rule) {
$this->rule[$name] = $rule;
} else {
$this->rule[] = $name;
}
$this->message[] = $msg;
return $this;
}
/**
* 获取验证规则
* @access public
* @return array
*/
public function getRule()
{
return $this->rule;
}
/**
* 获取验证字段名称
* @access public
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* 获取验证提示
* @access public
* @return array
*/
public function getMsg()
{
return $this->message;
}
/**
* 设置验证字段名称
* @access public
* @return $this
*/
public function title($title)
{
$this->title = $title;
return $this;
}
public function __call($method, $args)
{
if ('is' == strtolower(substr($method, 0, 2))) {
$method = substr($method, 2);
}
array_unshift($args, lcfirst($method));
return call_user_func_array([$this, 'addItem'], $args);
}
public static function __callStatic($method, $args)
{
$rule = new static();
if ('is' == strtolower(substr($method, 0, 2))) {
$method = substr($method, 2);
}
array_unshift($args, lcfirst($method));
return call_user_func_array([$rule, 'addItem'], $args);
}
}
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

Releases

No release

Contributors

All

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hyperf-plus/validate.git
git@gitee.com:hyperf-plus/validate.git
hyperf-plus
validate
validate
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /