stick-i / spel-validator

一个强大的 Java 参数校验包,基于 SpEL 实现,扩展自 javax.validation 包,用于简化参数校验,几乎支持所有场景下的参数校验。
https://spel-validator.sticki.cn/
Apache License 2.0
118 stars 26 forks source link

fix: 当验证对象类型不支持时抛出异常的逻辑错误 #2

Closed hmj776521114 closed 4 months ago

hmj776521114 commented 4 months ago

当把示例vo的代码改为


    @SpelNotBlank(condition = "#this.switchAudio == true", message = "语音内容不能为空")
    private String audioContent;

请求参数为:

{
  "switchAudio":true,
  "audioContent": null
}

响应结果为:

{
    "timestamp": "2024-05-09T04:36:45.128+00:00",
    "status": 500,
    "error": "Internal Server Error",
    "path": "/example/simple"
}

控制台报错:

cn.sticki.validator.spel.exception.SpelNotSupportedTypeException: Object class not supported, class: com.imashiamro.validatordemo.model.SimpleExampleParamVo, supperType: [interface java.lang.CharSequence]
stick-i commented 4 months ago

hi ,感谢你的反馈,这个地方确实是个bug,由于测试用例还不太完善,所以没有测到这个部分,抱歉🤡

stick-i commented 4 months ago

此bug已经在 0.0.3-beta 中修复