-
Notifications
You must be signed in to change notification settings - Fork 47
Added nested struct validation #128
base: master
Are you sure you want to change the base?
Added nested struct validation #128
Conversation
Added more descriptive req error message Reordered req check in order to fix, failing tests Signed-off-by: Anes Hasicic <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure passing the parent field is really worth it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I passed in the parent because I added return fmt.Errorf("missing field %v in %v", t.Name, parent.Name()) a parent to a missing field error.
I did it because if you have multiple fields with the same name in a struct and nested structs, the default missing field %v felt non descriptive, you wouldn't know which struct it belongs to. But if you feel like it's too much, I will remove it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the comment on line 760
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but I don't understand what that comment should point out me?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That comment is about adding the info about the parent type on the
if err != nil { return ... }
|
This is pretty good, but please add tests and address my comments. Thanks! |
|
@campoy Thanks, yes I will add tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't pass the type and instead just add the info to the error message.
return fmt.Errorf("%v in %s", err, t)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Added nested struct validation and more descriptive req error message.
Closes #107
Signed-off-by: Anes Hasicic [email protected]