gookit / validate

⚔ Go package for data validation and filtering. support Map, Struct, Form data. Go通用的数据验证与过滤库,使用简单,内置大部分常用验证、过滤器,支持自定义验证器、自定义消息、字段翻译。
https://gookit.github.io/validate/
MIT License
1.08k stars 116 forks source link

[Question] Can `in` be used with slice in tag validation? #266

Open chengc-sa opened 5 months ago

chengc-sa commented 5 months ago
type A struct{
   S []string `validate:"required|in:a,b"`
}

I basically want each element of S to be either a or b, but looks like in validation in the tag by default does not support validating a slice, I know you can do it using the programmatic validation (StringRule()), but I want to stick with tag validation, is there any workaround for it?