Documentation ¶
Index ¶
- Variables
- func BoolValidator(_ *Form, f *Field) string
- func FloatValidator(_ *Form, f *Field) string
- func FormBuilder() *formBuilder
- func IntValidator(_ *Form, f *Field) string
- func RequiredValidator(fo *Form, fi *Field) string
- func StringValidator(_ *Form, _ *Field) string
- func UIntValidator(_ *Form, f *Field) string
- type Field
- func BoolField(label string, opts ...FieldOption) *Field
- func DateField(label string, format string, opts ...FieldOption) *Field
- func FloatField(label string, opts ...FieldOption) *Field
- func IntField(label string, opts ...FieldOption) *Field
- func StrField(label string, opts ...FieldOption) *Field
- func UIntField(label string, opts ...FieldOption) *Field
- type FieldFilter
- type FieldOption
- type FieldValidator
- type Form
- type FormFillingFunc
- type FormValidator
- type ValidationErrors
- type Widget
Constants ¶
This section is empty.
Variables ¶
var DefaultMessages = map[string]map[string]string{
"en": {
"Boolean": "%s has invalid boolean value",
"Integer": "%s has invalid integer value",
"Float": "%s has invalid float value",
"Required": "%s is required",
"EqualToField": "%s does not match %s",
},
}
var Locale = "en"
Functions ¶
func BoolValidator ¶
BoolValidator validates if a field has a valid boolean value according to strconv.ParseBool with the addition of the value "on" (for HTML checkboxes)
func FloatValidator ¶
FloatValidator validates if a field is a valid 64-bit float
func FormBuilder ¶
func FormBuilder() *formBuilder
func IntValidator ¶
IntValidator validates if a field is a valid 64-bit integer
func RequiredValidator ¶
func StringValidator ¶
StringValidator validates if a field is a valid string. All fields are valid strings :)
func UIntValidator ¶
UIntValidator validates if a field contains a valid 64-bit unsigned integer
Types ¶
type Field ¶
type Field struct { Label string Validators []FieldValidator Description string ID string DefaultValue []string Type string // todo: not implemented yet Filters []FieldFilter Widget Widget // contains filtered or unexported fields }
func BoolField ¶
func BoolField(label string, opts ...FieldOption) *Field
BoolField creates a new boolean type field
func DateField ¶
func DateField(label string, format string, opts ...FieldOption) *Field
DateField creates a new date type field
func FloatField ¶
func FloatField(label string, opts ...FieldOption) *Field
FloatField creates a new float type field
func IntField ¶
func IntField(label string, opts ...FieldOption) *Field
IntField creates a new integer type field
func StrField ¶
func StrField(label string, opts ...FieldOption) *Field
StrField creates a new string type field
func UIntField ¶
func UIntField(label string, opts ...FieldOption) *Field
UIntField creates a new uint type field
type FieldFilter ¶
type FieldOption ¶
type FieldOption func(*Field)
func Description ¶
func Description(desc string) FieldOption
Description adds a description to the field
func EqualToField ¶
func EqualToField(fieldName string) FieldOption
EqualToField adds a EqualToFieldValidator to the field
func Validate ¶
func Validate(validators ...FieldValidator) FieldOption
Validate appends validators to the field
type FieldValidator ¶
func DateValidator ¶
func DateValidator(format string) FieldValidator
func EqualToFieldValidator ¶
func EqualToFieldValidator(otherName string) FieldValidator
type Form ¶
type Form struct { Fields map[string]*Field Errors ValidationErrors }