async-validator icon indicating copy to clipboard operation
async-validator copied to clipboard

使用transforms时,导致无法通过required校验,即便是不为空的值

Open wekerSnail opened this issue 3 years ago • 3 comments

{ required: true, message: '请选择请求方式', trigger: 'change', transform(value) { return (value === 1 || value === 2) ? value : '' } }

wekerSnail avatar Oct 15 '21 08:10 wekerSnail

我的疑问是检验不是应该在transforms之后么,为处理之后的值为什么不为空也无法通过检验

wekerSnail avatar Oct 15 '21 08:10 wekerSnail

value为1或2的时候transform返回value,其他值都返回‘’,你说处理之后的值不为空就是transform返回的值是1或2,那value的初始值也是1或2,不管required是在transforms之前还之后都会通过检验啊。没看懂你的描述

sdoyuxing avatar Jul 19 '22 08:07 sdoyuxing

https://github.com/react-component/async-validator/pull/2

crazyair avatar Apr 16 '24 03:04 crazyair