binding.BindIgnErr
instead.Name
-> name
UnitPrice
-> unit_price
binding.SetNameMapper
function, which accepts a function that is type of binding.NameMapper
.json:
struct tags instead of form:
.binding.Bind
is a convenient wrapper over the other handlers in this package. It does the following boilerplate for you:binding.ErrorHandler
, then default error handling will be applied. Otherwise, calls ErrorHandler.Error
method to perform custom error handling.Content-Type
will be used to know how to deserialize the requests.binding.Form
deserializes form data from the request, whether in the query string or as a form-urlencoded
payload. It only does these things:binding.Errors
into your own handler if you want to handle errors.binding.Form
, binding.MultipartForm
deserializes form data from a request into the struct you pass in. Additionally, this will deserialize a POST request that has a form of enctype="multipart/form-data"
. If the bound struct contains a field of type *multipart.FileHeader
(or []*multipart.FileHeader
), you also can read any uploaded files that were part of the form.binding.Form
, no error handling is performed, but you can get the errors in your handler by receiving a binding.Errors
type.binding.Form
, no error handling is performed, but you can get the errors and handle them yourself.binding.Validate
receives a populated struct and checks it for errors with basic rules. It will execute the Validator.Validate()
method on the struct, if it is a binding.Validator
.binding:"<Name>"
.OmitEmpty
Required
AlphaDash
-_
AlphaDashDot
-_
or .
Size(int)
MinSize(int)
MaxSize(int)
Range(int,int)
Email
Url
In(a,b,c,...)
NotIn(a,b,c,...)
Include(string)
Exclude(string)
Default(string)
binding:"Required;MinSize(10)"
.binding.Validator
interface like so:binding.AddParamRule
, it accepts type binding.ParamRule
as argument.binding.ErrorHandler
interface like so: