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

Method verifyString

ext/formatting_v2.go:565–602  ·  view source on GitHub ↗
(sub ast.Expr)

Source from the content-addressed store, hash-verified

563}
564
565func (c *stringFormatCheckerV2) verifyString(sub ast.Expr) (bool, int64) {
566 paramA := cel.TypeParamType("A")
567 paramB := cel.TypeParamType("B")
568 subVerified := c.verifyTypeOneOf(sub.ID(),
569 cel.ListType(paramA), cel.MapType(paramA, paramB),
570 cel.IntType, cel.UintType, cel.DoubleType, cel.BoolType, cel.StringType,
571 cel.TimestampType, cel.BytesType, cel.DurationType, cel.TypeType, cel.NullType)
572 if !subVerified {
573 return false, sub.ID()
574 }
575 switch sub.Kind() {
576 case ast.ListKind:
577 for _, e := range sub.AsList().Elements() {
578 // recursively verify if we're dealing with a list/map
579 verified, id := c.verifyString(e)
580 if !verified {
581 return false, id
582 }
583 }
584 return true, sub.ID()
585 case ast.MapKind:
586 for _, e := range sub.AsMap().Entries() {
587 // recursively verify if we're dealing with a list/map
588 entry := e.AsMapEntry()
589 verified, id := c.verifyString(entry.Key())
590 if !verified {
591 return false, id
592 }
593 verified, id = c.verifyString(entry.Value())
594 if !verified {
595 return false, id
596 }
597 }
598 return true, sub.ID()
599 default:
600 return true, sub.ID()
601 }
602}
603
604// helper routines for reporting common errors during string formatting static validation and
605// 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