Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropwizard-like validation #24

Open
wadey opened this issue Aug 5, 2013 · 5 comments
Open

Dropwizard-like validation #24

wadey opened this issue Aug 5, 2013 · 5 comments

Comments

@wadey
Copy link
Collaborator

wadey commented Aug 5, 2013

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

@wadey
Copy link
Collaborator Author

wadey commented Nov 5, 2013

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.

@rcrowley
Copy link
Owner

rcrowley commented Nov 5, 2013

This seems like a good use of tags. I like it.

@bigkevmcd
Copy link
Contributor

@wadey
Copy link
Collaborator Author

wadey commented May 2, 2014

@bigkevmcd Perfect! This package is exactly what I wanted.

@pjvds
Copy link

pjvds commented Oct 26, 2015

Just for reference, the link @bigkevmcd provided is dead. Here is the new one: https://github.com/go-validator/validator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants