Open
Description
Package version eg. v9, v10:
v10
Issue, Question or Enhancement:
Question: using variables in the validation tag
Suppose I have the following struct:
type Payload struct {
Quantity int
Items []Item
}
How do I proceed to do the following validation: len(Items) = Quantity
I tried the following:
Items []Item `validate:"len=eqfield=Quantity"
and also tried this
Item []Item `validate:"len=Quantity"`
And have been looking at the Validate.Var
and Validate.VarWithValue
functions but wondering if there's any neater approach, especially that I'm using translations and don't want to repeat my code.
Thank you so much in advance, Your work is greatly appreciated.