Documentation
¶
Overview ¶
Package data provides ways to declare validation constraints on values, these constraints can be reflected upon at runtime.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ErrExceeds ¶
type ErrExceeds struct { Limit string // contains filtered or unexported fields }
func (*ErrExceeds) Error ¶
func (err *ErrExceeds) Error() string
func (*ErrExceeds) StatusHTTP ¶
func (err *ErrExceeds) StatusHTTP() int
func (*ErrExceeds) WithFieldNameSetTo ¶
func (err *ErrExceeds) WithFieldNameSetTo(name string) error
type ErrInvalid ¶
func (*ErrInvalid) Error ¶
func (err *ErrInvalid) Error() string
func (*ErrInvalid) StatusHTTP ¶
func (err *ErrInvalid) StatusHTTP() int
func (*ErrInvalid) WithFieldNameSetTo ¶
func (err *ErrInvalid) WithFieldNameSetTo(name string) error
type ErrMissing ¶
type ErrMissing struct {
// contains filtered or unexported fields
}
func (*ErrMissing) Error ¶
func (err *ErrMissing) Error() string
func (*ErrMissing) StatusHTTP ¶
func (err *ErrMissing) StatusHTTP() int
func (*ErrMissing) WithFieldNameSetTo ¶
func (err *ErrMissing) WithFieldNameSetTo(name string) error
type ReportingMapped ¶
type ReportingMapped[K comparable, V any] struct { // Invalid reports an error if the number does not match the given // 'format' string. 'hints' are optional and can be used to provide // additional information about the specification of the format. Invalid func(class string, fn func(map[K]V) bool, hints ...string) error // Exceeds reports an error if the length of the map is greater // than the given limit. Exceeds func(int) error // ForEach iterates over each element in the map and reports an // error if the given function returns an error. ForEach func(func(*V) error) error // MapKeys iterates over each key in the map and reports an error // if the given function returns an error. MapKeys func(func(*K) error) error // Missing reports an error if the length of the map is equal to 0. Missing func() error }
func Mapped ¶
func Mapped[K comparable, V any](value *map[K]V) ReportingMapped[K, V]
Mapped identifies a map field to validate.
type ReportingNumber ¶
type ReportingNumber[T numeric] struct { // Invalid reports an error if the number does not match the given // 'format' string. 'hints' are optional and can be used to provide // additional information about the specification of the format. Invalid func(format string, fn func(T) bool, hints ...string) error // Missing reports an error if the field is equal to 0. Missing func() error }
func Number ¶
func Number[T numeric](value *T) ReportingNumber[T]
Number identifies a numeric field to report on.
type ReportingObject ¶
type ReportingObject[T any] struct { // Reports checks the given errors and returns a new error if any // of them are not nil. Reports func(...error) error }
func Object ¶
func Object[T any](value *T) ReportingObject[T]
type ReportingSliced ¶
type ReportingSliced[T any] struct { // Invalid reports an error if the number does not match the given // 'format' string. 'hints' are optional and can be used to provide // additional information about the specification of the format. Invalid func(class string, fn func([]T) bool, hints ...string) error // ForEach iterates over each element in the slice and reports an // error if the given function returns an error. ForEach func(func(*T) error) error // Exceeds reports an error if the length of the slice is greater // than the given limit. Exceeds func(int) error // Missing reports an error if the length of the slice is equal to 0. Missing func() error }
func Sliced ¶
func Sliced[T any](value *[]T) ReportingSliced[T]
Sliced identifies a slice field to validate.
type ReportingString ¶
type ReportingString[T ~string | ~[]byte] struct { // Invalid reports an error if the number does not match the given // 'format' string. 'hints' are optional and can be used to provide // additional information about the specification of the format. Invalid func(class string, fn func(T) bool, hints ...string) error // Exceeds reports an error if the length of the string is greater // than the given limit. Exceeds func(limit int) error // Missing reports an error if the field is equal to the zero value // of T. Missing func() error }
func String ¶
func String[T ~string | ~[]byte](value *T) ReportingString[T]
String identifies a string field to validate.
Click to show internal directories.
Click to hide internal directories.