binding
binding copied to clipboard
Package binding is a middleware that provides request data binding and validation for Macaron.
Have been trying to set up a JSON Post Request using the Macaron Example ``` type ContactForm struct { Name string `json:"name" binding:"Required"` } r.Post("/api/journals", binding.Bind(ContactForm{}), func(contact ContactForm) string {...
Seee https://github.com/go-macaron/binding/pull/32
In Go's net/http ParseForm() method, the following checks are done: https://github.com/golang/go/blob/700e969d5b23732179ea86cfe67e8d1a0a1cc10a/src/net/http/request.go#L1176 // For other HTTP methods, or when the Content-Type is not // application/x-www-form-urlencoded, the request Body is not read,...
The custom validation on the example is not working. ````golang func init() { // Min(1) set de minimun integer value binding.AddRule(&binding.Rule{ IsMatch: func(rule string) bool { return strings.HasPrefix(rule, "Min(") },...
It seems that the JSON part supports having multiple "sub-forms" (slices of structs ?). I would like to have something like (not File Uploads here, plain HTML input forms): ```go...
``` go color *string `binding:"OmitEmpty;Size(7)"` ```
Is it possible to change the pattern [binding.go#L247](https://github.com/go-macaron/binding/blob/master/binding.go#L247) to **"[^\d\p{L}-_\.]"** ? (also L246) I want to use Unicode names for repositories in gogs.
This works: ``` go type UploadForm struct { Title string `form:"Title"` TextUpload *multipart.FileHeader `form:"TextUpload"` } ``` But this produces an empty struct: ``` go type UploadForm struct { Title string...
Validate 和Error 对指针的处理方式不统一, 前者接受指针类型而后者不接受 // 这样的方法不被识别 func (form *VariantForm) Error(ctx *macaron.Context, errs binding.Errors) {} // macaron 识别这样的方法 func (form *VariantForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {}
I would like to be able to apply validation rules to each item in a slice. eg ``` type MyStruct struct { Id int MyNumbers []int `json:"my_numbers" binding:"range(1, 10)"` }...