Skip to content

Commit

Permalink
feat: call validate on unmarshal
Browse files Browse the repository at this point in the history
TRA-1296
  • Loading branch information
fredrikaverpil committed Apr 10, 2024
1 parent d7df62c commit 59bc82d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/protoc-gen-go-aip/internal/genaip/resourcename.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ func (r resourceNameCodeGenerator) generateUnmarshalStringMethod(
})
g.P()
g.P("func (n *", typeName, ") UnmarshalString(name string) error {")
g.P("if err := n.Validate(); err != nil {")
g.P("return err")
g.P("}")
g.P("return ", resourcenameSscan, "(")
g.P("name,")
g.P(strconv.Quote(pattern), ",")
Expand Down

0 comments on commit 59bc82d

Please sign in to comment.