MCPcopy Create free account
hub / github.com/cel-expr/cel-go / validatorIntConfig

Function validatorIntConfig

cel/validator.go:610–626  ·  view source on GitHub ↗
(val *env.Validator, configKey string)

Source from the content-addressed store, hash-verified

608}
609
610func 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}

Callers 1

Calls 1

ConfigValueMethod · 0.80

Tested by

no test coverage detected