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.

[SOLVED] Custom message for .number() / . string() etc (without additional parameters)

See original GitHub issue
 numberField: Yup.number("Not a numbBar")
    .integer("Please enter a whole number")
    .required("Please enter price, enter 0 for a free class"),

Cannot seem to find in docs how to display a custom message, for .number()?

1 - number; 2 - integer; 3 - required. 2 and 3 works as expected.

3 - .number() returns this: numberField must be a numbertype, but the final value was:NaN(cast from the value"foobar ").

Would like to return a custom message

Thanks

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:10
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

62reactions
jquensecommented, Oct 7, 2018

.typeError() I believe is the method for setting that

20reactions
JClackettcommented, Dec 16, 2019

amount: Yup.number().typeError(“Must be a number”),

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom Excel number format - Ablebits
This tutorial explains the basics of the Excel number format and provides the detailed guidance to create custom formatting.
Read more >
HTML5 form required attribute. Set custom validation message?
So I set the pattern attribute to check for numbers and optional decimals which gives the message, "Please match the requested format," on...
Read more >
Java Generics Example Tutorial - Generic Method, Class ...
Above code compiles fine but throws ClassCastException at runtime because we are trying to cast Object in the list to String whereas one...
Read more >
6 Ways to Fix Dates Formatted as Text in Excel
No mention of the Text() function to convert the numeric value to a string? Big omission. Reply. Mynda Treacy. September 21, 2019 at...
Read more >
JavaScript language overview - MDN Web Docs
The Number() function, which parses a string as if it's a number literal ... Number values also include NaN (short for "Not a...
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