From bfd592b5ddf133b532b061e822e52139551e7f26 Mon Sep 17 00:00:00 2001 From: Patrick Pacher Date: Wed, 15 Apr 2020 09:49:24 +0200 Subject: [PATCH] Fix validation error for floats --- config/validate.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/validate.go b/config/validate.go index 6807eb2..3db4871 100644 --- a/config/validate.go +++ b/config/validate.go @@ -70,7 +70,8 @@ func validateValue(option *Option, value interface{}) (*valueCache, error) { //n return nil, fmt.Errorf("expected type %s for option %s, got type %T", getTypeName(option.OptType), option.Key, v) } if option.compiledRegex != nil { - if !option.compiledRegex.MatchString(fmt.Sprintf("%d", v)) { + // we need to use %v here so we handle float and int correctly. + if !option.compiledRegex.MatchString(fmt.Sprintf("%v", v)) { return nil, fmt.Errorf("validation of option %s failed: number \"%d\" did not match validation regex", option.Key, v) } }