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

Method verifyString

ext/formatting.go:625–662  ·  view source on GitHub ↗
(sub ast.Expr)

Source from the content-addressed store, hash-verified

623}
624
625func (c *stringFormatChecker) verifyString(sub ast.Expr) (bool, int64) {
626 paramA := cel.TypeParamType("A")
627 paramB := cel.TypeParamType("B")
628 subVerified := c.verifyTypeOneOf(sub.ID(),
629 cel.ListType(paramA), cel.MapType(paramA, paramB),
630 cel.IntType, cel.UintType, cel.DoubleType, cel.BoolType, cel.StringType,
631 cel.TimestampType, cel.BytesType, cel.DurationType, cel.TypeType, cel.NullType)
632 if !subVerified {
633 return false, sub.ID()
634 }
635 switch sub.Kind() {
636 case ast.ListKind:
637 for _, e := range sub.AsList().Elements() {
638 // recursively verify if we're dealing with a list/map
639 verified, id := c.verifyString(e)
640 if !verified {
641 return false, id
642 }
643 }
644 return true, sub.ID()
645 case ast.MapKind:
646 for _, e := range sub.AsMap().Entries() {
647 // recursively verify if we're dealing with a list/map
648 entry := e.AsMapEntry()
649 verified, id := c.verifyString(entry.Key())
650 if !verified {
651 return false, id
652 }
653 verified, id = c.verifyString(entry.Value())
654 if !verified {
655 return false, id
656 }
657 }
658 return true, sub.ID()
659 default:
660 return true, sub.ID()
661 }
662}
663
664// helper routines for reporting common errors during string formatting static validation and
665// runtime execution.

Callers 1

StringMethod · 0.95

Calls 10

verifyTypeOneOfMethod · 0.95
IDMethod · 0.65
KindMethod · 0.65
ElementsMethod · 0.65
AsListMethod · 0.65
EntriesMethod · 0.65
AsMapMethod · 0.65
AsMapEntryMethod · 0.65
KeyMethod · 0.65
ValueMethod · 0.65

Tested by

no test coverage detected