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

Function Format

dsl/validation.go:149–163  ·  view source on GitHub ↗

Format adds a "format" validation to the attribute. See http://json-schema.org/latest/json-schema-validation.html#anchor104. The formats supported by goa are: FormatDate: RFC3339 date FormatDateTime: RFC3339 date time FormatUUID: RFC4122 uuid FormatEmail: RFC5322 email address FormatHostname: R

(f expr.ValidationFormat)

Source from the content-addressed store, hash-verified

147// Format(FormatDateTime)
148// })
149func Format(f expr.ValidationFormat) {
150 if a, ok := eval.Current().(*expr.AttributeExpr); ok {
151 if !a.IsSupportedValidationFormat(f) {
152 eval.ReportError("invalid validation format %q", f)
153 }
154 if a.Type != nil && a.Type.Kind() != expr.StringKind {
155 incompatibleAttributeType("format", a.Type.Name(), "a string")
156 } else {
157 if a.Validation == nil {
158 a.Validation = &expr.ValidationExpr{}
159 }
160 a.Validation.Format = f
161 }
162 }
163}
164
165// Pattern adds a "pattern" validation to the attribute.
166// See http://json-schema.org/latest/json-schema-validation.html#anchor33.

Callers 10

TestFormatFunction · 0.70
payload_dsls.goFile · 0.50
AliasStringBodyDSLFunction · 0.50
dsls.goFile · 0.50
type_spec_test.goFile · 0.50

Calls 6

CurrentFunction · 0.92
ReportErrorFunction · 0.92
KindMethod · 0.65
NameMethod · 0.65