Closed haklop closed 9 years ago
Use gopkg.in/bluesuncorp/validator.v5 to validate submitted JSON.
Simply add the validate tag on a field to set constraints:
type Project struct { ScmType string `bson:"scm_type" json:"scm_type" validate:"required"` ScmURI string `bson:"scm_uri" json:"scm_uri" validate:"required"` Name string `bson:"name" json:"name" validate:"required"` ID string `bson:"id" json:"id"` JobCounter int `bson:"job_counter" json:"job_counter"` Config map[string]string `bson:"config" json:"config"` }
We can use all the validators defined here https://godoc.org/gopkg.in/bluesuncorp/validator.v5#hdr-Baked_In_Validators_and_Tags
It's possible to create custom validator if necessary.
I use the package reflect to generate friendly error messages.
LGTM but it needs to be rebased to be merged
Use gopkg.in/bluesuncorp/validator.v5 to validate submitted JSON.
Simply add the validate tag on a field to set constraints:
We can use all the validators defined here https://godoc.org/gopkg.in/bluesuncorp/validator.v5#hdr-Baked_In_Validators_and_Tags
It's possible to create custom validator if necessary.
I use the package reflect to generate friendly error messages.