mirror of
https://github.com/safing/portbase
synced 2025-09-01 10:09:50 +00:00
Merge pull request #31 from safing/fix/config-int-float
Fix validation error for floats
This commit is contained in:
commit
812c1e26c5
1 changed files with 2 additions and 1 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue