(val *env.Validator, configKey string)
| 608 | } |
| 609 | |
| 610 | func validatorIntConfig(val *env.Validator, configKey string) (int, error) { |
| 611 | if limit, found := val.ConfigValue(configKey); found { |
| 612 | // In case of protos, config value is of type google.protobuf.Value, which numeric values are always a double. |
| 613 | if v, isDouble := limit.(float64); isDouble { |
| 614 | if v != float64(int64(v)) { |
| 615 | return 0, fmt.Errorf("invalid validator: %s, %s value is not a whole number: %v", val.Name, configKey, limit) |
| 616 | } |
| 617 | return int(v), nil |
| 618 | } |
| 619 | |
| 620 | if v, isInt := limit.(int); isInt { |
| 621 | return v, nil |
| 622 | } |
| 623 | return 0, fmt.Errorf("invalid validator: %s unsupported %s type: %v", val.Name, configKey, limit) |
| 624 | } |
| 625 | return 0, fmt.Errorf("invalid validator: %s missing %s", val.Name, configKey) |
| 626 | } |
no test coverage detected