Documentation ¶
Overview ¶
Package validation provides functionality to validate form data and present translatable errors.
Index ¶
- type AddressChecker
- type BoolChecker
- type CustomError
- type CustomFormattedError
- type DateChecker
- type DateMissingCheck
- type DateMissingError
- type DateMustBePastCheck
- type DateMustBePastError
- type DateMustBeRealCheck
- type DateMustBeRealError
- type EmailCheck
- type EmailError
- type EmptyCheck
- type EnterError
- type ErrorChecker
- type Field
- type FileError
- type FilesInfectedError
- type FormattableError
- type List
- func (l *List) Add(name string, error FormattableError)
- func (l *List) Address(name, label string, value *place.Address, checks ...AddressChecker)
- func (l List) Any() bool
- func (l *List) Append(other List) List
- func (l *List) Bool(name, label string, value bool, checks ...BoolChecker)
- func (l *List) Date(name, label string, value date.Date, checks ...DateChecker)
- func (l *List) Error(name, label string, value error, checks ...ErrorChecker)
- func (l List) Format(localizer Localizer, name string) string
- func (l List) Has(name string) bool
- func (l List) HasForDate(name, part string) bool
- func (l List) None() bool
- func (l *List) Options(name, label string, value []string, checks ...OptionsChecker)
- func (l *List) String(name, label, value string, checks ...StringChecker)
- func (l List) With(name string, error FormattableError) List
- type Localizer
- type OptionsChecker
- type PhoneCheck
- type PhoneError
- type PostcodeCheck
- type PostcodeError
- type ReferenceNumberCheck
- type ReferenceNumberError
- type SelectCheck
- type SelectError
- type SelectedCheck
- func (c SelectedCheck) CheckAddress(label string, value *place.Address) FormattableError
- func (c SelectedCheck) CheckBool(label string, value bool) FormattableError
- func (c SelectedCheck) CheckError(label string, err error) FormattableError
- func (c SelectedCheck) CheckOptions(label string, value []string) FormattableError
- func (c SelectedCheck) CustomError() SelectedCheck
- type StringChecker
- type StringLengthCheck
- type StringLengthError
- type StringTooLongCheck
- type StringTooLongError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddressChecker ¶
type AddressChecker interface {
CheckAddress(string, *place.Address) FormattableError
}
type BoolChecker ¶
type BoolChecker interface {
CheckBool(string, bool) FormattableError
}
type CustomError ¶
type CustomError struct {
Label string
}
func (CustomError) Format ¶
func (e CustomError) Format(l Localizer) string
type CustomFormattedError ¶ added in v0.1308.0
func (CustomFormattedError) Format ¶ added in v0.1308.0
func (e CustomFormattedError) Format(l Localizer) string
type DateChecker ¶
type DateChecker interface {
CheckDate(string, date.Date) FormattableError
}
type DateMissingCheck ¶
type DateMissingCheck struct{}
func DateMissing ¶
func DateMissing() DateMissingCheck
func (DateMissingCheck) CheckDate ¶
func (c DateMissingCheck) CheckDate(label string, date date.Date) FormattableError
type DateMissingError ¶
type DateMissingError struct { Label string // need to highlight the correct fields, if all then EnterError should be used MissingDay bool MissingMonth bool MissingYear bool }
func (DateMissingError) Format ¶
func (e DateMissingError) Format(l Localizer) string
type DateMustBePastCheck ¶
type DateMustBePastCheck struct{}
func DateMustBePast ¶
func DateMustBePast() DateMustBePastCheck
func (DateMustBePastCheck) CheckDate ¶
func (c DateMustBePastCheck) CheckDate(label string, value date.Date) FormattableError
type DateMustBePastError ¶
type DateMustBePastError struct {
Label string
}
func (DateMustBePastError) Format ¶
func (e DateMustBePastError) Format(l Localizer) string
type DateMustBeRealCheck ¶
type DateMustBeRealCheck struct{}
func DateMustBeReal ¶
func DateMustBeReal() DateMustBeRealCheck
func (DateMustBeRealCheck) CheckDate ¶
func (c DateMustBeRealCheck) CheckDate(label string, value date.Date) FormattableError
type DateMustBeRealError ¶
type DateMustBeRealError struct {
Label string
}
func (DateMustBeRealError) Format ¶
func (e DateMustBeRealError) Format(l Localizer) string
type EmailCheck ¶
type EmailCheck struct{}
func Email ¶
func Email() EmailCheck
func (EmailCheck) CheckString ¶
func (c EmailCheck) CheckString(label, value string) FormattableError
type EmailError ¶
type EmailError struct {
Label string
}
func (EmailError) Format ¶
func (e EmailError) Format(l Localizer) string
type EmptyCheck ¶
type EmptyCheck struct{}
func Empty ¶
func Empty() EmptyCheck
func (EmptyCheck) CheckString ¶
func (c EmptyCheck) CheckString(label, value string) FormattableError
type EnterError ¶
type EnterError struct {
Label string
}
func (EnterError) Format ¶
func (e EnterError) Format(l Localizer) string
type ErrorChecker ¶
type ErrorChecker interface {
CheckError(label string, value error) FormattableError
}
type Field ¶
type Field struct { Name string Error FormattableError }
type FilesInfectedError ¶ added in v0.794.0
func (FilesInfectedError) Format ¶ added in v0.794.0
func (e FilesInfectedError) Format(l Localizer) string
type FormattableError ¶
type List ¶
type List []Field
func With ¶
func With(name string, error FormattableError) List
func (*List) Add ¶
func (l *List) Add(name string, error FormattableError)
func (*List) Address ¶
func (l *List) Address(name, label string, value *place.Address, checks ...AddressChecker)
func (List) HasForDate ¶
func (*List) Options ¶
func (l *List) Options(name, label string, value []string, checks ...OptionsChecker)
func (*List) String ¶
func (l *List) String(name, label, value string, checks ...StringChecker)
type OptionsChecker ¶
type OptionsChecker interface {
CheckOptions(string, []string) FormattableError
}
type PhoneCheck ¶ added in v0.1105.0
type PhoneCheck struct {
// contains filtered or unexported fields
}
func Mobile ¶
func Mobile() PhoneCheck
func NonUKMobile ¶
func NonUKMobile() PhoneCheck
func Phone ¶ added in v0.1380.0
func Phone() PhoneCheck
func (PhoneCheck) CheckString ¶ added in v0.1105.0
func (c PhoneCheck) CheckString(label, value string) FormattableError
func (PhoneCheck) ErrorLabel ¶ added in v0.1105.0
func (c PhoneCheck) ErrorLabel(label string) PhoneCheck
type PhoneError ¶ added in v0.1105.0
func (PhoneError) Format ¶ added in v0.1105.0
func (e PhoneError) Format(l Localizer) string
type PostcodeCheck ¶ added in v0.696.0
type PostcodeCheck struct{}
func Postcode ¶ added in v0.696.0
func Postcode() PostcodeCheck
func (PostcodeCheck) CheckString ¶ added in v0.696.0
func (c PostcodeCheck) CheckString(label, value string) FormattableError
type PostcodeError ¶ added in v0.696.0
type PostcodeError struct {
Label string
}
func (PostcodeError) Format ¶ added in v0.696.0
func (e PostcodeError) Format(l Localizer) string
type ReferenceNumberCheck ¶ added in v0.789.0
type ReferenceNumberCheck struct{}
func ReferenceNumber ¶ added in v0.789.0
func ReferenceNumber() ReferenceNumberCheck
func (ReferenceNumberCheck) CheckString ¶ added in v0.789.0
func (c ReferenceNumberCheck) CheckString(label, value string) FormattableError
type ReferenceNumberError ¶ added in v0.789.0
type ReferenceNumberError struct {
Label string
}
func (ReferenceNumberError) Format ¶ added in v0.789.0
func (e ReferenceNumberError) Format(l Localizer) string
type SelectCheck ¶
type SelectCheck struct {
// contains filtered or unexported fields
}
func Select ¶
func Select(in ...string) SelectCheck
func (SelectCheck) CheckOptions ¶
func (c SelectCheck) CheckOptions(label string, value []string) FormattableError
func (SelectCheck) CheckString ¶
func (c SelectCheck) CheckString(label string, value string) FormattableError
func (SelectCheck) CustomError ¶
func (c SelectCheck) CustomError() SelectCheck
type SelectError ¶
type SelectError struct {
Label string
}
func (SelectError) Format ¶
func (e SelectError) Format(l Localizer) string
type SelectedCheck ¶
type SelectedCheck struct {
// contains filtered or unexported fields
}
func Selected ¶
func Selected() SelectedCheck
func (SelectedCheck) CheckAddress ¶
func (c SelectedCheck) CheckAddress(label string, value *place.Address) FormattableError
func (SelectedCheck) CheckBool ¶
func (c SelectedCheck) CheckBool(label string, value bool) FormattableError
func (SelectedCheck) CheckError ¶
func (c SelectedCheck) CheckError(label string, err error) FormattableError
func (SelectedCheck) CheckOptions ¶
func (c SelectedCheck) CheckOptions(label string, value []string) FormattableError
func (SelectedCheck) CustomError ¶
func (c SelectedCheck) CustomError() SelectedCheck
type StringChecker ¶
type StringChecker interface {
CheckString(label, value string) FormattableError
}
type StringLengthCheck ¶
type StringLengthCheck struct {
// contains filtered or unexported fields
}
func StringLength ¶
func StringLength(length int) StringLengthCheck
func (StringLengthCheck) CheckString ¶
func (c StringLengthCheck) CheckString(label, value string) FormattableError
type StringLengthError ¶
func (StringLengthError) Format ¶
func (e StringLengthError) Format(l Localizer) string
type StringTooLongCheck ¶
type StringTooLongCheck struct {
// contains filtered or unexported fields
}
func StringTooLong ¶
func StringTooLong(length int) StringTooLongCheck
func (StringTooLongCheck) CheckString ¶
func (c StringTooLongCheck) CheckString(label, value string) FormattableError
type StringTooLongError ¶
func (StringTooLongError) Format ¶
func (e StringTooLongError) Format(l Localizer) string
Click to show internal directories.
Click to hide internal directories.