Documentation
¶
Index ¶
- Variables
- type Boolean
- func (field *Boolean) GetDefault() interface{}
- func (field *Boolean) GetError(code string, parameters ...interface{}) error
- func (field *Boolean) GetName() string
- func (field *Boolean) GetValidators() []validators.Validator
- func (field *Boolean) IsRequired() bool
- func (field *Boolean) Validate(v interface{}) (interface{}, error)
- type Datetime
- func (field *Datetime) GetDefault() interface{}
- func (field *Datetime) GetError(code string, parameters ...interface{}) error
- func (field *Datetime) GetName() string
- func (field *Datetime) GetValidators() []validators.Validator
- func (field *Datetime) IsRequired() bool
- func (field *Datetime) Validate(v interface{}) (interface{}, error)
- type Email
- func (field *Email) GetDefault() interface{}
- func (field *Email) GetError(code string, parameters ...interface{}) error
- func (field *Email) GetName() string
- func (field *Email) GetValidators() []validators.Validator
- func (field *Email) IsRequired() bool
- func (field *Email) Validate(v interface{}) (interface{}, error)
- type Field
- type Float
- func (field *Float) GetDefault() interface{}
- func (field *Float) GetError(code string, parameters ...interface{}) error
- func (field *Float) GetName() string
- func (field *Float) GetValidators() []validators.Validator
- func (field *Float) IsRequired() bool
- func (field *Float) Validate(v interface{}) (interface{}, error)
- type Integer
- func (field *Integer) GetDefault() interface{}
- func (field *Integer) GetError(code string, parameters ...interface{}) error
- func (field *Integer) GetName() string
- func (field *Integer) GetValidators() []validators.Validator
- func (field *Integer) IsRequired() bool
- func (field *Integer) Validate(v interface{}) (interface{}, error)
- type String
- func (field *String) GetDefault() interface{}
- func (field *String) GetError(code string, parameters ...interface{}) error
- func (field *String) GetName() string
- func (field *String) GetValidators() []validators.Validator
- func (field *String) IsRequired() bool
- func (field *String) Validate(v interface{}) (interface{}, error)
- type URL
- func (field *URL) GetDefault() interface{}
- func (field *URL) GetError(code string, parameters ...interface{}) error
- func (field *URL) GetName() string
- func (field *URL) GetValidators() []validators.Validator
- func (field *URL) IsRequired() bool
- func (field *URL) Validate(v interface{}) (interface{}, error)
Constants ¶
This section is empty.
Variables ¶
var BooleanErrors = map[string]string{
"Required": "This field is required.",
"Invalid": "Ensure this value is a valid boolean.",
}
BooleanErrors is a code-error mapping for Boolean field.
var DatetimeErrors = map[string]string{
"Required": "This field is required.",
"Invalid": "Ensure this value is a valid datetime string.",
}
DatetimeErrors is a code-error mapping for Datetime field.
var EmailErrors = map[string]string{
"Required": "This field is required.",
"Invalid": "Ensure this value is valid email string.",
}
EmailErrors is a code-error mapping for Email field.
var FloatErrors = map[string]string{
"Required": "This field is required.",
"Invalid": "Ensure this value is a valid float.",
}
FloatErrors is a code-error mapping for Float field.
var IntegerErrors = map[string]string{
"Required": "This field is required.",
"Invalid": "Ensure this value is valid integer.",
"MinValue": "Ensure this value is greater than or equal to %v.",
"MaxValue": "Ensure this value is less than or equal to %v.",
}
IntegerErrors is a code-error mapping for Integer field.
var StringErrors = map[string]string{
"Required": "This field is required.",
"Invalid": "Ensure this value is valid string.",
"Blank": "Blank strings aren't allowed.",
"MinLength": "Ensure this value has at least %v characters.",
"MaxLength": "Ensure this value has at most %v characters.",
}
StringErrors is a code-error mapping for String field.
var URLErrors = map[string]string{
"Required": "This field is required.",
"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.Validator
Required bool
Default bool
Errors map[string]string
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) GetValidators ¶
func (field *Boolean) GetValidators() []validators.Validator
GetValidators returns additional field validators.
func (*Boolean) IsRequired ¶
IsRequired returns true if field is required.
type Datetime ¶
type Datetime struct {
Name string
Validators []validators.Validator
Required bool
Default float64
Errors map[string]string // Overrides default errors
}
Datetime is integer field.
func (*Datetime) GetDefault ¶
func (field *Datetime) GetDefault() interface{}
GetDefault returns the default value.
func (*Datetime) GetValidators ¶
func (field *Datetime) GetValidators() []validators.Validator
GetValidators returns additional field validators.
func (*Datetime) IsRequired ¶
IsRequired returns true if field is required.
type Email ¶
type Email struct {
Name string
Validators []validators.Validator
Required bool
Default float64
Errors map[string]string // Overrides default errors
}
Email is integer field.
func (*Email) GetDefault ¶
func (field *Email) GetDefault() interface{}
GetDefault returns the default value.
func (*Email) GetValidators ¶
func (field *Email) GetValidators() []validators.Validator
GetValidators returns additional field validators.
func (*Email) IsRequired ¶
IsRequired returns true if field is required.
type Field ¶
type Field interface {
GetName() string
GetValidators() []validators.Validator
IsRequired() bool
GetDefault() interface{}
GetError(code string, parameters ...interface{}) error
Validate(value interface{}) (interface{}, error)
}
Field describes a field interface.
type Float ¶
type Float struct {
Name string
Validators []validators.Validator
Required bool
Default float64
Errors map[string]string // Overrides default errors
AllowStrings bool
MinValue *validators.MinValueValidator
MaxValue *validators.MaxValueValidator
}
Float is float field.
func (*Float) GetDefault ¶
func (field *Float) GetDefault() interface{}
GetDefault returns the default value.
func (*Float) GetValidators ¶
func (field *Float) GetValidators() []validators.Validator
GetValidators returns additional field validators.
func (*Float) IsRequired ¶
IsRequired returns true if field is required.
type Integer ¶
type Integer struct {
Name string
Validators []validators.Validator
Required bool
Default int
Errors map[string]string // Overrides default errors
AllowStrings bool
MinValue *validators.MinValueValidator
MaxValue *validators.MaxValueValidator
}
Integer is integer field.
func (*Integer) GetDefault ¶
func (field *Integer) GetDefault() interface{}
GetDefault returns the default value.
func (*Integer) GetValidators ¶
func (field *Integer) GetValidators() []validators.Validator
GetValidators returns additional field validators.
func (*Integer) IsRequired ¶
IsRequired returns true if field is required.
type String ¶
type String struct {
Name string
Validators []validators.Validator
Required bool
Default string
Errors map[string]string
AllowBlank bool
MinLength *validators.MinLengthValidator
MaxLength *validators.MaxLengthValidator
}
String is boolean field.
func (*String) GetDefault ¶
func (field *String) GetDefault() interface{}
GetDefault returns the default value.
func (*String) GetValidators ¶
func (field *String) GetValidators() []validators.Validator
GetValidators returns additional field validators.
func (*String) IsRequired ¶
IsRequired returns true if field is required.
type URL ¶
type URL struct {
Name string
Validators []validators.Validator
Required bool
Default float64
Errors map[string]string // Overrides default errors
}
URL is integer field.
func (*URL) GetDefault ¶
func (field *URL) GetDefault() interface{}
GetDefault returns the default value.
func (*URL) GetValidators ¶
func (field *URL) GetValidators() []validators.Validator
GetValidators returns additional field validators.
func (*URL) IsRequired ¶
IsRequired returns true if field is required.