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

Function validatorIntConfig

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

Source from the content-addressed store, hash-verified

599}
600
601func validatorIntConfig(val *env.Validator, configKey string) (int, error) {
602 if limit, found := val.ConfigValue(configKey); found {
603 // In case of protos, config value is of type google.protobuf.Value, which numeric values are always a double.
604 if v, isDouble := limit.(float64); isDouble {
605 if v != float64(int64(v)) {
606 return 0, fmt.Errorf("invalid validator: %s, %s value is not a whole number: %v", val.Name, configKey, limit)
607 }
608 return int(v), nil
609 }
610
611 if v, isInt := limit.(int); isInt {
612 return v, nil
613 }
614 return 0, fmt.Errorf("invalid validator: %s unsupported %s type: %v", val.Name, configKey, limit)
615 }
616 return 0, fmt.Errorf("invalid validator: %s missing %s", val.Name, configKey)
617}

Callers 1

validator.goFile · 0.85

Calls 1

ConfigValueMethod · 0.80

Tested by

no test coverage detected