添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
微醺的荔枝  ·  Use ...·  1 周前    · 
聪明的作业本  ·  Vibration Test ...·  6 天前    · 
温暖的鸵鸟  ·  Error thrown - ...·  21 小时前    · 
没人理的豆芽  ·  Support·  6 月前    · 
私奔的炒饭  ·  Eugen Coroianu, autor ...·  6 月前    · 

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

While sendAPIRequest is pending and former test pass, previous result of former one is not reflected.

const formerTest = string().matches(/123/, 'error 1')
return object().shape({
  A: formerTest.test('latterTest', 'error 2', async (value) => {
    if (await formerTest.isValid(value)) {
      return await sendAPIRequest(value)
  }),
// example
// input 12 -> show 'error 1' -> input 123 -> 
// still show 'error 1'(I think it's not should come out) and promise is pending state -> 
// promise resolved, disaapear 'error 1' and show (or not) 'error 2'

How to show formerTest 's result regardless of promise status?

I'm not sure I understand what you are trying to accomplish.

Would something like this suffice?

const schema = yup.string().matches(/123/, 'error 1')
const res = await schema.validate('your input here')
await sendAPIRequest(res)

Or are you trying to get all the error messages first? If that's case you need to set abortEarly to false :

const schema = yup.string().matches(/123/, 'error 1').matches(/321/, 'error 2')
schema
    .validate('your input', { abortEarly: false })
    .then(res => console.log(`success: ${res}`))
    .catch(e => console.log(`error: ${e.errors}`)) // => error 1, error 2