Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var IsRequired = validation.Required
IsRequired is an alias to validation.Required
var IsRequiredOrNull = validation.NilOrNotEmpty
IsRequiredOrNull is an alias to validation.NilOrNotEmpty
var IsValidEmail = is.Email
IsValidEmail adds an error to the field if it's not a valid email address
Functions ¶
func Bind ¶
Bind loads and validates the data using the method tied to the request's content-type header.
func IsValidURL ¶
func IsValidURL(schemes map[string]bool) validation.StringRule
IsValidURL checks is a url is a valid http or https url.
Types ¶
type Errors ¶
type Errors []error
Errors is a error list that is attached to a form or a field.
func (Errors) MarshalJSON ¶
MarshalJSON performs the error list's JSON serialization.
type Field ¶
type Field struct { Name string Type reflect.Type Errors Errors // contains filtered or unexported fields }
Field represents a form field.
func (*Field) MarshalJSON ¶
MarshalJSON performs the field's JSON serialization.
func (*Field) Validate ¶
func (f *Field) Validate(rules ...validation.Rule)
Validate applies the given validation rules to the field. When the validation fails, it adds an error to the field so it can be retrieved later.
type FieldValidator ¶
FieldValidator is the interface for a field that implements its internal validation.
type Form ¶
type Form struct { Fields map[string]*Field Errors Errors // contains filtered or unexported fields }
Form contains the data instance and the derived fields that can be used in a template or returned in a JSON response.
func NewForm ¶
func NewForm(instance interface{}) *Form
NewForm creates a new form instance and defines the derived fields.
func (*Form) BindValues ¶
BindValues binds the values from any URL encoded value list.
func (*Form) MarshalJSON ¶
MarshalJSON performs the form's JSON serialization.
func (*Form) SetContext ¶
SetContext set the new form's context