go-tigertonic
go-tigertonic copied to clipboard
Dropwizard-like validation
Dropwizard has a nice integration with Hibernate Validator that makes it easy to give good error messages when the user provides an incorrect JSON payload (e.g. missing a key).
See: http://dropwizard.codahale.com/manual/core/#validation
One way I envision this is being able to add some additional tags to my request structs, like so:
type MyRequest struct {
ID string `json:"id" validate:"notempty"`
Name string `json:"name"`
}
If a POST request came in with a MyRequest body that didn't have an ID, then it would return a 400 with some information about why.
I have been searching to see if any go libraries exist that do this, but I haven't found anything yet.
This seems like a good use of tags. I like it.
http://robteix.com/blog/2014/04/29/package-validate/
@bigkevmcd Perfect! This package is exactly what I wanted.
Just for reference, the link @bigkevmcd provided is dead. Here is the new one: https://github.com/go-validator/validator