MCPcopy Create free account
hub / github.com/brimdata/super / Validate

Method Validate

value.go:480–501  ·  view source on GitHub ↗

Validate checks that v.Bytes is structurally consistent with v.Type. It does not check that the actual leaf values when parsed are type compatible with the leaf types.

()

Source from the content-addressed store, hash-verified

478// with v.Type. It does not check that the actual leaf
479// values when parsed are type compatible with the leaf types.
480func (v Value) Validate() (err error) {
481 defer func() {
482 if r := recover(); r != nil {
483 err = fmt.Errorf("panic: %+v\n%s", r, debug.Stack())
484 }
485 }()
486 return v.Walk(func(typ Type, body scode.Bytes) error {
487 if _, ok := typ.(*TypeSet); ok {
488 if err := checkSet(body); err != nil {
489 return err
490 }
491 return SkipContainer
492 }
493 if typ, ok := typ.(*TypeEnum); ok {
494 if err := checkEnum(typ, body); err != nil {
495 return err
496 }
497 return SkipContainer
498 }
499 return nil
500 })
501}
502
503func checkSet(body scode.Bytes) error {
504 it := body.Iter()

Callers 1

TestValueValidateFunction · 0.95

Calls 3

WalkMethod · 0.95
checkSetFunction · 0.85
checkEnumFunction · 0.85

Tested by 1

TestValueValidateFunction · 0.76