Documentation ¶
Overview ¶
Package goforms/fields provides various types of fields for validating and cleaning individual form values.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseField ¶
The types that are embedded/shared with more specific field types.
func (BaseField) CleanArray ¶
func (f BaseField) CleanArray([]string) (interface{}, ValidationError)
Returns true if this field support array.
func (BaseField) IsRequired ¶
Returns whether data for this field is required.
type BoolField ¶
type BoolField struct {
BaseField
}
func NewBoolField ¶
Create and initialise the new fields with the given defaults.
func (BoolField) Clean ¶
func (f BoolField) Clean(value string) (interface{}, ValidationError)
Check whether the given string value is valid for this field and return the cleaned value or a relevant error.
type CharField ¶
func NewCharField ¶
Create and initialise the new fields with the given defaults.
func NewJSONField ¶
Create and initialise the new fields with the given defaults.
func (CharField) Clean ¶
func (f CharField) Clean(value string) (interface{}, ValidationError)
Check whether the given string value is valid for this field and return the cleaned value or a relevant error.
type Field ¶
type Field interface { Clean(string) (interface{}, ValidationError) CleanArray([]string) (interface{}, ValidationError) IsRequired() bool IsArray() bool }
A field is able to clean a string value to the correct type or indicate a relevant error, as well as determine whether it is required.
type IntegerField ¶
type IntegerField struct {
BaseField
}
func NewIntegerField ¶
func NewIntegerField(defaults Defaults) IntegerField
Create and initialise the new fields with the given defaults.
func (IntegerField) Clean ¶
func (f IntegerField) Clean(value string) (interface{}, ValidationError)
Check whether the given string value is valid for this field and return the cleaned value or a relevant error.
func (IntegerField) IsRequired ¶
func (f IntegerField) IsRequired() bool
type JSONField ¶
type JSONField struct {
BaseField
}
func (JSONField) Clean ¶
func (f JSONField) Clean(value string) (interface{}, ValidationError)
Check whether the given string value is valid for this field and return the cleaned value or a relevant error.
type RegexField ¶
func NewRegexField ¶
func NewRegexField(defaults Defaults) RegexField
Create and initialise the new fields with the given defaults.
func (RegexField) Clean ¶
func (f RegexField) Clean(value string) (interface{}, ValidationError)
Check whether the given string value is valid for this field and return the cleaned value or a relevant error.
type ValidationError ¶
type ValidationError interface {
Error() string
}