How to use required_if
when checking if a field equals a string with spaces in it?
#1085
Unanswered
geoff-maddock
asked this question in
Q&A
Replies: 1 comment
-
In this case, you have to use the Hex code of the space which is Stage *string
ChurnReason *string `validate:"required_if=stage Churn0x20Reason"` See the docs : https://pkg.go.dev/github.com/go-playground/validator/v10#hdr-Using_Validator_Tags |
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
-
I'm trying to use
required_if
to validate requiring a field if another field equals a specific string that has a space in it. However, I can't determine the correct format for the expression. Here are the examples I've tried and the results. In every caseChurn Reason
is nil:This succeeds, no validation error - there should be an error since Churn Reason is required and it is not provided.
This returns an error
Bad param number for required_if ChurnReason
This returns an error
Bad param number for required_if ChurnReason
Beta Was this translation helpful? Give feedback.
All reactions