jamieomatthews · GitHub

After coming from .NET MVC, I am accustom to model binding. However, there were many more validation rules you could set on the model fields.

For example, now you have

 type BlogPost struct {
    Title   string    `form:"title" json:"title" binding:"required"`
}

And you have the "Binding:required", which will add an error if its not there. Is there any chance you'd consider adding some other validation tags, like for example, marking a field as an email? There are some other really common ones too, like credit card, date, minlength, maxlength etc. Sure you could just add your own validator, but it would be nice to be able to add these to the model and have that taken care of for you:

type BlogPost struct {
        Title   string    `form:"title" json:"title" binding:"required" minlength:"10"`
        Email   string    `form:"title" json:"title" binding:"required" email:"true"`
 }

The syntax above is just an example, not necessarily how I would do it. Is this something that might belong here?

Read the original on github.com ↗