Closed attilaolah closed 10 years ago
Well, it is rather conventional in Go to export constructor functions in this fashion. I don't mind. In a future commit I'll add some godoc comments to the function and mention that it's really only useful for testing; in other cases the errors struct is provided for you.
Either way, merging in. Thanks!
This way, when someone writes unit tests against structs that implements the
binding.Validator
interface, they don't have to manually set up the*binding.Errors
parameter themselves. They can simply callbinding.NewError()
.Note that this method is only intended to be used in tests.
binding
will take care of initialising the*Errors
parameter before callingValidate
.Let me know if anyone has a better idea. I don't like exporting too much, and it bothers me somewhat that this is needed purely for testing. But I can't think of anything better.