javascript - Yup validation decimal number
问题描述
Thank you in advance, I'm using yup in my React project to validate my schema, problem is in field called "price":
price: Yup.number().required("Required"),
when I add value with comma like 45,89
yup throw me an error that price must be a number. I'm like that float with comma is same like float with dot.
Is there a way to take current value from validation schema and replace it? like current.replace(",",".")
?
解决方案
you can use typeError(message: string): Schema
to define an error message for failed type checks. The ${value}
and ${type}
interpolation can be used in the message argument.
推荐阅读
- c# - 如何枚举64位进程的所有模块?
- python - Finding similar looking items from a dataframe using python
- c# - 在 C# 中的 EWS 中保存内联附件
- java - I am trying to take to char inputs from a single string using Scanner with .charAt()
- sql - How to increment with limited value
- image - 无法将 docker 图像推送到我的 docker hub 帐户中
- javascript - Why we do extends React.Component when creating the class component in React?
- mysql - Select group multiple records by specific condition
- java - How to end threads in a specific order using join() /wait() /notify combination?
- r - 在 Tableau 中集成 R 的时间序列模型