src/AppBundle/Common/SimpleValidator.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace AppBundle\Common;
/**
* 一个简单的验证类.
*/
class SimpleValidator
{
public static function email($value)
{
$value = (string) $value;
$valid = filter_var($value, FILTER_VALIDATE_EMAIL);
return $valid !== false;
}
public static function nickname($value, array $option = array())
{
$option = array_merge(
array('minLength' => 4, 'maxLength' => 18),
$option
);
$len = (strlen($value) + mb_strlen($value, 'utf-8')) / 2;
if ($len > $option['maxLength'] || $len < $option['minLength']) {
return false;
}
if (preg_match('/^1\d{10}$/', $value)) {
return false;
}
return (bool) preg_match('/^[\x{4e00}-\x{9fa5}a-zA-z0-9_.·]+$/u', $value);
}
public static function password($value, array $option = array())
{
return (bool) preg_match('/^[\S]{5,20}$/u', $value);
}
//真实姓名改成和nickname一样
public static function truename($value, array $option = array())
{
$option = array_merge(
array('minLength' => 4, 'maxLength' => 18),
$option
);
$len = (strlen($value) + mb_strlen($value, 'utf-8')) / 2;
if ($len > $option['maxLength'] || $len < $option['minLength']) {
return false;
}
if (preg_match('/^1\d{10}$/', $value)) {
return false;
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。