feat: validate value in options for mapping (#2616)

This commit is contained in:
Kevin Wan
2022-11-18 19:46:23 +08:00
committed by GitHub
parent 79de932646
commit 06fafd2153
2 changed files with 155 additions and 70 deletions

View File

@@ -341,6 +341,10 @@ func (u *Unmarshaler) processFieldTextUnmarshaler(field reflect.StructField, val
func (u *Unmarshaler) processFieldWithEnvValue(field reflect.StructField, value reflect.Value,
envVal string, opts *fieldOptionsWithContext, fullName string) error {
if err := validateValueInOptions(envVal, opts.options()); err != nil {
return err
}
fieldKind := field.Type.Kind()
switch fieldKind {
case reflect.Bool: