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

Created on 7 Oct 2018  路  5Comments  路  Source: jquense/yup

 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 anumbertype, but the final value was:NaN(cast from the value"foobar ").

Would like to return a custom message

Thanks

Most helpful comment

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

All 5 comments

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

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

Thank you sir, this is what I was looking for!

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

how do you get to use it

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

How do I remove the array sign [missing....]

Was this page helpful?
0 / 5 - 0 ratings

Related issues

you-fail-me picture you-fail-me  路  4Comments

ghost picture ghost  路  4Comments

the-daniel-rothig picture the-daniel-rothig  路  4Comments

AmineIT picture AmineIT  路  3Comments

cfteric picture cfteric  路  3Comments