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 9a702a7
Show file tree
Hide file tree
Showing 7 changed files with 51 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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions proto/gen/einride/example/freight/v1/shipment_aip.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions proto/gen/einride/example/freight/v1/shipper_aip.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions proto/gen/einride/example/freight/v1/site_aip.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9a702a7

Please sign in to comment.