Hi,
I have a field that is only present if another field has a certain value.
type A struct {
Type string `validate:"in:B,C"`
B
C
}
type B struct {
ID string `validate:"required_if:A.Type,B|uuid4"
}
So B's ID must be a UUID, but only if A's type is B.
So this is allowed:
A{
Type: "B",
B: {
ID: "94e48bd3-e990-405e-bd10-304e767cd3fd"
},
}
But this is not allowed:
A{
Type: "C",
B: {
ID: "94e48bd3-e990-405e-bd10-304e767cd3fd"
},
}
And this is not allowed:
A{
Type: "B",
B: {
ID: ""
},
}
Do you know how I would achieve this with your library? Thank you!
Hi,
I have a field that is only present if another field has a certain value.
So B's ID must be a UUID, but only if A's type is B.
So this is allowed:
But this is not allowed:
And this is not allowed:
Do you know how I would achieve this with your library? Thank you!