Closed tpng closed 9 years ago
On limitation 2:
func (person Person) Validate(errs Errors, req *http.Request) Errors {
...
}
This will panic on nil pointer, so need to check for nil pointer using the following version:
func (person *Person) Validate(errs Errors, req *http.Request) Errors {
if person == nil {
// add some errors or else
return errs
}
...
}
I'm glad you documented the limitations here. I think they are acceptable considering how elegant the solution is otherwise. Thanks!
limitation: 1) no validations performed on the embedded struct fields if the pointer is not binded (similar issue for json binding) 2) only support pointer receiver for the Validator interface for the embedded pointer, and the Validator will need to check for nil receiver
suggestion: it might be safer to leave the newed embedded struct as is (without resetting to nil value) even if nothing is binded for the field, to overcome the above limitation
Closes #30