question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

when does not work with number

See original GitHub issue

I get error: TypeError: Cannot read property 'length' of undefined

For example I have this validation:

const agreementDurationAmount = Yup.number().when('agreementDuration', (agreementDuration) => {
  if(agreementDuration === 'Miesięczny') {
    return Yup.number().min(1, 'Czas trwania umowy: wprowadź liczbę miesięcy');
  }
  if(agreementDuration === 'Tygodniowy') {
    return Yup.number().min(1, 'Czas trwania umowy: wprowadź liczbę tygodni');
  }
  return Yup.number();
});

And such object:

{
  agreementDuration: 'Nieokreślony',
  agreementDurationAmount: 0,
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
liltechnomancercommented, Jul 19, 2018

If anyones reading this. If you use when in a schema the field it depends on should also be in the schema. So @wieseljonas would need to declare a type and rules for mainType in the same schema as landSurface.

3reactions
rofrolcommented, Aug 29, 2017

Works, I just needed to add:

agreementPenaltyEnable: yup.boolean(),

Like this:

export const uodValidation = yup.object().shape({
  agreementPenaltyEnable: yup.boolean(),
  agreementPenalty,
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

[SOLVED] Keyboard numbers not working - Driver Easy
If the NumLock key is enabled and the number keys still don't work, you can try pressing the NumLock key for about 5...
Read more >
Fix: Keyboard Not Typing Numbers in Windows 10 - Techbout
The most common reason for laptop keyboard not typing numbers is due to the Num Lock key being accidentally disabled. Depending on the...
Read more >
What to Do If Keyboard Number Keys Are Not Working on ...
How to Fix Number Keys Not Working Windows 10/11 · Fix 1: Turn off Mouse Key · Enable the NumLock Key · Update...
Read more >
Top 8 Ways to Fix Number Pad Not Working on Keyboard in ...
Top 8 Ways to Fix Number Pad Not Working on Keyboard in Windows 11 · 1. Enable Num Lock on Keyboard · 2....
Read more >
Keyboard Not Typing Numbers - Why And How To Fix It
How to Fix Keyboard Not Typing Numbers · Turn Off Mouse Keys · Check for Stuck Shift and Alt Keys · Turn Off...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found