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

How we can use yup.when() ? #28

Open
iarpittomar opened this issue May 10, 2022 · 1 comment
Open

How we can use yup.when() ? #28

iarpittomar opened this issue May 10, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@iarpittomar
Copy link

iarpittomar commented May 10, 2022

I am trying something like this

`[
['yup.object'],
[
'yup.shape',
{
email: [
['yup.string'],
['yup.nullable'],
[
'yup.required',
'Bitte geben Sie eine gültige E-Mail-Adresse ein (maximal 320 Zeichen).',
],
],

      roleRespresentative: [['yup.boolean'], ['yup.default', 'false']],

      email2: [
        ['yup.string'],
        ['yup.nullable'],
        [
          'yup.when',
          'roleRespresentative',
          {
            is: true,
            then: [
              [
                'yup.required',
                'Bitte geben Sie eine gültige E-Mail-Adresse ein (maximal 320 Zeichen).',
              ],
            ],
          },
        ],
      ],     
    },
  ],
]`
@kassuro kassuro added the bug Something isn't working label May 11, 2022
@kassuro
Copy link
Contributor

kassuro commented May 11, 2022

Hi, so I'm also not that deep into the code as I only maintain it now, but I played a little with your example it seems yup.shape makes problems, since I can't get the schema to transform when it's defined.
But the main problem is that it seems the new nested schema parts from yup.when won't get appended to the schema correctly.

So for now my guess is yup.when doesn't work correctly at this time.
Unfortunately we do not use the lib that much anymore so I can't say when I get around to investigate this problem.
Feel free to solve it yourself and make a PR if you have the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants