ValidationCode produces Go code that runs the validations defined in the given attribute and its children recursively against the value held by the variable named target. put is the parent UserType if any. It is used to compute proto oneof type names. attCtx is the attribute context used to genera
(att *expr.AttributeExpr, put expr.UserType, attCtx *AttributeContext, req, alias, view bool, target string)
| 88 | // |
| 89 | // context is used to produce helpful messages in case of error. |
| 90 | func ValidationCode(att *expr.AttributeExpr, put expr.UserType, attCtx *AttributeContext, req, alias, view bool, target string) string { |
| 91 | return recurseValidationCode(att, put, attCtx, req, alias, view, target, target, nil).String() |
| 92 | } |
| 93 | |
| 94 | func recurseValidationCode(att *expr.AttributeExpr, put expr.UserType, attCtx *AttributeContext, req, alias, view bool, target, context string, seen map[string]*bytes.Buffer) *bytes.Buffer { |
| 95 | if seen == nil { |