We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v10.14.0
Now expecting validation to fail because of discount_type=discount outside
https://go.dev/play/p/N4JEKaJQDSe
package main import ( "fmt" "github.com/go-playground/validator/v10" ) type StorePromotion struct { BatchStair []StairItem `json:"batch_stair" validate:"required,dive"` DiscountType string `json:"discount_type" validate:"required,oneof=amount discount"` } type StairItem struct { SubjectNum int8 `json:"subject_num" validate:"required"` Value int64 `json:"value" validate:"required"` Limit int64 `json:"limit" validate:"required_if=DiscountType discount"` # It doesn't work } func main() { validate := validator.New() s := &StorePromotion{ DiscountType: "discount", BatchStair: []StairItem{ {SubjectNum: 1, Value: 100, Limit: 100}, {SubjectNum: 2, Value: 90}, {SubjectNum: 3, Value: 80}, }, } err := validate.Struct(s) fmt.Println(err) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Package version v10:
v10.14.0
Issue, Question or Enhancement:
Now expecting validation to fail because of discount_type=discount outside
Code sample, to showcase or reproduce:
https://go.dev/play/p/N4JEKaJQDSe
The text was updated successfully, but these errors were encountered: