Skip to content

参数注解顺序和必填验证失效问题 #11

@wilson9x

Description

@wilson9x

EasySwoole\HttpAnnotation\AnnotationController line(250), 校验的参数被赋值默认null. 导致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"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions