Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

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

Error when use when combined with lazy #381

Closed
Ridermansb opened this issue Nov 28, 2018 · 0 comments · Fixed by #447
Closed

Error when use when combined with lazy #381

Ridermansb opened this issue Nov 28, 2018 · 0 comments · Fixed by #447

Comments

@Ridermansb
Copy link

Ridermansb commented Nov 28, 2018

I received this error targetVal.concat is not a function​​ at ​​​merge​​​

const creditCardSchema = yup.object().shape({
  addressNumber: yup.lazy(val => {
    switch (typeof val) {
      case "number":
        return yup.number()
      default:
        return yup
          .string()
          .matches(/(S\/N)/i);
    }
  })
});

const paymentSchema = yup.object().shape({
  creditCard: yup.object().when("paymentMethod", {
    is: "credit_card",
    then: creditCardSchema
  }),
  paymentMethod: yup.string().required()
});

const checkoutSchema = yup.object().shape({
  payment: paymentSchema
});

checkoutSchema.validate({
    payment: {
        paymentMethod: "credit_card"
    }
}); // Throw errror targetVal.concat is not a function​​
  at ​​​merge​​​ 

You can check online ...
https://runkit.com/ridermansb/yup-error-when-lazy

@Ridermansb Ridermansb changed the title Erro when use when combined with lazy Error when use when combined with lazy Nov 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant