Validate count struct fields

This commit is contained in:
Kovid Goyal 2022-09-21 06:40:03 +05:30
parent a3a89b3e21
commit 0cf8876f8a
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -74,6 +74,9 @@ func OptionsFromStruct(pointer_to_options_struct interface{}) ([]*Option, error)
if err != nil {
return nil, err
}
if opt.OptionType == CountOption && f.Kind() != reflect.Int {
return nil, fmt.Errorf("The field %s is of count type but in the options struct it does not have type int", field_name)
}
ans = append(ans, opt)
}