Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call Validate() when unmarshalling resource name #288

Merged
merged 1 commit into from
Apr 11, 2024

Conversation

fredrikaverpil
Copy link
Member

@fredrikaverpil fredrikaverpil commented Apr 10, 2024

We are calling Validate() on marshalling but not on unmarshalling a resource name. This PR fixes that.

@fredrikaverpil fredrikaverpil self-assigned this Apr 10, 2024
@fredrikaverpil fredrikaverpil marked this pull request as ready for review April 10, 2024 15:00
@fredrikaverpil fredrikaverpil requested a review from a team as a code owner April 10, 2024 15:00
@fredrikaverpil fredrikaverpil changed the title Call Validate() when Unmarshalling Call Validate() when Unmarshalling resource name Apr 10, 2024
@fredrikaverpil fredrikaverpil changed the title Call Validate() when Unmarshalling resource name Call Validate() when unmarshalling resource name Apr 10, 2024
Copy link
Member

@odsod odsod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO makes sense to Validate() in the generated methods - good thinking!

if err != nil {
return err
}
if err := n.Validate(); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could return the error directly.
return n.Validate()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, nice - great suggestion, and so obvious now that I realize the return signature is identical!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Member

@thall thall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet!

@fredrikaverpil fredrikaverpil merged commit 1a8c18f into master Apr 11, 2024
1 check passed
@fredrikaverpil fredrikaverpil deleted the tra-1296-call-validate branch April 11, 2024 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants