validation

package
v0.1298.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

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 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 FileError added in v0.692.0

type FileError struct {
	Label    string
	Filename string
}

func (FileError) Format added in v0.692.0

func (e FileError) Format(l Localizer) string

type FilesInfectedError added in v0.794.0

type FilesInfectedError struct {
	Label     string
	Filenames []string
}

func (FilesInfectedError) Format added in v0.794.0

func (e FilesInfectedError) Format(l Localizer) string

type FormattableError

type FormattableError interface {
	Format(Localizer) string
}

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) Any

func (l List) Any() bool

func (*List) Append added in v0.1105.0

func (l *List) Append(other List) List

func (*List) Bool

func (l *List) Bool(name, label string, value bool, checks ...BoolChecker)

func (*List) Date

func (l *List) Date(name, label string, value date.Date, checks ...DateChecker)

func (*List) Error

func (l *List) Error(name, label string, value error, checks ...ErrorChecker)

func (List) Format

func (l List) Format(localizer Localizer, name string) string

func (List) Has

func (l List) Has(name string) bool

func (List) HasForDate

func (l List) HasForDate(name, part string) bool

func (List) None

func (l List) None() bool

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)

func (List) With

func (l List) With(name string, error FormattableError) List

type Localizer

type Localizer interface {
	Concat([]string, string) string
	Format(string, map[string]any) string
	FormatCount(string, int, map[string]interface{}) string
	T(string) string
}

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 Telephone added in v0.1105.0

func Telephone() 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

type PhoneError struct {
	Tmpl  string
	Label string
}

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

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

type StringLengthError struct {
	Label  string
	Length int
}

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

type StringTooLongError struct {
	Label  string
	Length int
}

func (StringTooLongError) Format

func (e StringTooLongError) Format(l Localizer) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL