Need different validations for Save as draft and Submit button in form. #2944
Unanswered
amanchanna
asked this question in
Q&A
Replies: 4 comments 10 replies
-
why not just use |
Beta Was this translation helpful? Give feedback.
8 replies
-
@amanchanna did you ever solve this? |
Beta Was this translation helpful? Give feedback.
2 replies
-
Is this problem still unsolved? Im also facing this particular issue. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hello!
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a form having Save as draft and Submit button. I am using schema based validations using Yup. The validations for Save as draft and Submit button are different.
Basically the user can save as draft even if the required fields are not filled but other validations like max length and amount format etc. should be checked while doing Save as draft.
All the validations including the required one should be applied when doing Submit.
For e.g - We have an amount field that is required and should not be of length more than 14. The validations should be as follows:
For Submit:
amount: yup.string().required().max(14)
For Save as Draft:
amount: yup.string().max(14)
Is there a way we can have different schema for different button click or any other better way to handle this condition in react hook form?
Beta Was this translation helpful? Give feedback.
All reactions