【发布时间】:2022-08-05 02:51:41
【问题描述】:
是的,异步验证测试被多次调用。有没有办法只在值发生变化或阻止对相同值的验证检查时调用测试
const validationSchema = yup.object().shape({
zipCode: yup.string().required()
.test(\'invalidZip\', \'ZipCode must be valid\', (value, context) => {
/**
* api call to validate zip code
* this is getting called multiple times even though there is no change in
* zipCode.
* I want to run this test only if there is change in value
*/
return new Promise.resolve((resolve) => Utils.validateZipCode(value, resolve));
})
});