Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var BooleanErrors = map[uint]string{ codes.Unknown: "Unknown error.", codes.Required: "This field is required.", codes.Invalid: "Ensure this value is a valid boolean.", }
BooleanErrors is a code-error mapping for Boolean field.
var DatetimeErrors = map[uint]string{ codes.Required: "This field is required.", codes.Invalid: "Ensure this value is a valid datetime string.", }
DatetimeErrors is a code-error mapping for Datetime field.
var EmailErrors = map[uint]string{ codes.Required: "This field is required.", codes.Invalid: "Ensure this value is valid email string.", }
EmailErrors is a code-error mapping for Email field.
var FloatErrors = map[uint]string{ codes.Required: "This field is required.", codes.Invalid: "Ensure this value is a valid float.", codes.MinValue: "Ensure this value is greater than or equal to %f.", codes.MaxValue: "Ensure this value is less than or equal to %f.", }
FloatErrors is a code-error mapping for Float field.
var IntegerErrors = map[uint]string{ codes.Required: "This field is required.", codes.Invalid: "Ensure this value is valid integer.", codes.MinValue: "Ensure this value is greater than or equal to %d.", codes.MaxValue: "Ensure this value is less than or equal to %d.", }
IntegerErrors is a code-error mapping for Integer field.
var StringErrors = map[uint]string{ codes.Required: "This field is required.", codes.Invalid: "Ensure this value is valid string.", codes.Blank: "Blank strings aren't allowed.", codes.MinLength: "Ensure this value has at least %d characters.", codes.MaxLength: "Ensure this value has at most %d characters.", }
StringErrors is a code-error mapping for String field.
var URLErrors = map[uint]string{ codes.Required: "This field is required.", codes.Invalid: "Ensure this value is valid URL string.", }
URLErrors is a code-error mapping for URL field.
Functions ¶
This section is empty.
Types ¶
type Boolean ¶
type Boolean struct {
Name string
Validators []validators.BooleanValidator
Required bool
Default bool
Errors map[uint]string
ErrorFunc ErrorFunc
AllowStrings bool // Allow pass strings "t", "true", "f", "false" as valid boolean.
AllowNumbers bool // Allow pass numbers 0 or 1 as valid boolean.
}
Boolean is boolean field.
func (*Boolean) GetDefault ¶
func (field *Boolean) GetDefault() interface{}
GetDefault returns the default value.
func (*Boolean) IsRequired ¶
IsRequired returns true if field is required.
type Datetime ¶
type Datetime struct {
Name string
Validators []validators.DatetimeValidator
Required bool
Default time.Time
Errors map[uint]string
ErrorFunc ErrorFunc
}
Datetime is integer field.
func (*Datetime) GetDefault ¶
func (field *Datetime) GetDefault() interface{}
GetDefault returns the default value.
func (*Datetime) IsRequired ¶
IsRequired returns true if field is required.
type Email ¶
type Email struct {
Name string
Validators []validators.StringValidator
Required bool
Default string
Errors map[uint]string
ErrorFunc ErrorFunc
}
Email is integer field.
func (*Email) GetDefault ¶
func (field *Email) GetDefault() interface{}
GetDefault returns the default value.
func (*Email) IsRequired ¶
IsRequired returns true if field is required.
type Field ¶
type Field interface {
GetName() string
IsRequired() bool
GetDefault() interface{}
GetError(code uint, value interface{}, parameters ...interface{}) error
Validate(value interface{}) (interface{}, error)
}
Field describes a field interface.
type Float ¶
type Float struct {
Name string
Validators []validators.FloatValidator
Required bool
Default float64
Errors map[uint]string
ErrorFunc ErrorFunc
AllowStrings bool
}
Float is float field.
func (*Float) GetDefault ¶
func (field *Float) GetDefault() interface{}
GetDefault returns the default value.
func (*Float) IsRequired ¶
IsRequired returns true if field is required.
type Integer ¶
type Integer struct {
Name string
Validators []validators.IntegerValidator
Required bool
Default int
Errors map[uint]string
ErrorFunc ErrorFunc
AllowStrings bool
}
Integer is integer field.
func (*Integer) GetDefault ¶
func (field *Integer) GetDefault() interface{}
GetDefault returns the default value.
func (*Integer) IsRequired ¶
IsRequired returns true if field is required.
type String ¶
type String struct {
Name string
Validators []validators.StringValidator
Required bool
Default string
Errors map[uint]string
ErrorFunc ErrorFunc
AllowBlank bool
}
String is boolean field.
func (*String) GetDefault ¶
func (field *String) GetDefault() interface{}
GetDefault returns the default value.
func (*String) IsRequired ¶
IsRequired returns true if field is required.
type URL ¶
type URL struct {
Name string
Validators []validators.StringValidator
Required bool
Default float64
Errors map[uint]string
ErrorFunc ErrorFunc
}
URL is integer field.
func (*URL) GetDefault ¶
func (field *URL) GetDefault() interface{}
GetDefault returns the default value.
func (*URL) IsRequired ¶
IsRequired returns true if field is required.