Open enj opened 9 years ago
I can confirm that this does not work even if you use pointers, eg:
type Tester struct {
Value string `json:"value" endpoints:"req"`
}
type Thing struct {
A string `json:"a" endpoints:"req"`
T *Tester `json:"t" endpoints:"req"`
}
It would be great if we could get any feedback on this.
@campoy Ok, I did a fork and started implementing nested struct validation, it seemed pretty straight forward, and it basicaally is, but how do we distinguish between our own struct types and predefined ones we do not wish to validate.
Example:
type Tester struct {
Value string `json:"value" endpoints:"req"`
}
type Thing struct {
A string `json:"a" endpoints:"req"`
Timestamp time.Time `json:"timestamp" endpoints:"req"
T Tester `json:"t" endpoints:"req"`
}
time.Time
is also a struct but how and we wouldn't wish to validate it, what is your opinion on how do we distinguish it from for example Tester
struct. (add another tag maybe ???)
PS: I'm talking about validating the contents (fields) of those struct fields not the fields themselves. We want to validate time.Time field but not it's members.
@enj Ok I got it working, nested structs are now validated with req, you can find it here https://github.com/aneshas/go-endpoints @campoy don't know if you would accept a PR
Hey sorry for the delay, I totally missed this bug! :disappointed:
Could you create an actual PR so I can easily see the changes?
Thanks, @aneshas !
@campoy Hey, yes, I'll post it today
Does "req" not work with nested structs? The following does not throw an error when
{"a":"s"}
is sent as aThing
request value (I would thinkt
andt.value
would be required).