We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EasySwoole\HttpAnnotation\AnnotationController
required
notEmpty
@Param(name="name",required="",lengthMin="2",lengthMax="25",alias="姓名") //未传递name参数, 验证结果如下(必填验证未生效): // {"code":400,"result":null,"msg":"姓名长度不能超过25"}
EasySwoole\HttpAnnotation\AnnotationTag\Param->allowValidateRule
@Param(name="url",notEmpty="",url="",lengthMin="5",lengthMax="120",alias="链接地址") //传递url值为 xx, , 验证结果如下(应当先进行url合法性验证): {"code":400,"result":null,"msg":"链接地址长度不能小于5"}
The text was updated successfully, but these errors were encountered:
1、required被调用的时候,不填写任何数据,会成为空字符串, 此时!== null是成立.而required的底层判断是isset函数. 2、没有办法去获取用户的注解规则顺序,肯定也会有人先去判断length,再去判断是否为url.为什么你没有传入数据,会导致报长度错误,是因为此时的值不属于php的标量,所以validate为false,因此触发参数异常. 3、两个验证规则,a和b,a先验证失败和b先验证失败有区别?
!== null
isset
length
url
php
validate
false
a
b
Sorry, something went wrong.
No branches or pull requests
EasySwoole\HttpAnnotation\AnnotationController
line(250), 校验的参数被赋值默认null. 导致required
不生效, 只能使用notEmpty
提取校验规则顺序是通过
EasySwoole\HttpAnnotation\AnnotationTag\Param->allowValidateRule
固定顺序进行遍历提取, 不能按照注解的规则顺序进行校验The text was updated successfully, but these errors were encountered: