MCPcopy Create free account
hub / github.com/goadesign/goa / checkPattern

Function checkPattern

expr/example.go:385–398  ·  view source on GitHub ↗
(a *AttributeExpr, example any)

Source from the content-addressed store, hash-verified

383}
384
385func checkPattern(a *AttributeExpr, example any) bool {
386 if !hasPatternValidation(a) {
387 return true
388 }
389 pattern := a.Validation.Pattern
390 re, err := regexp.Compile(pattern)
391 if err != nil {
392 panic("Validation: invalid pattern '" + pattern + "'")
393 }
394 if !re.MatchString(fmt.Sprint(example)) {
395 return false
396 }
397 return true
398}
399
400func checkMinMaxValue(a *AttributeExpr, example any) bool {
401 if !hasMinMaxValidation(a) {

Callers 1

ExampleMethod · 0.85

Calls 2

hasPatternValidationFunction · 0.85
CompileMethod · 0.80

Tested by

no test coverage detected