Documentation
¶
Overview ¶
Package valid contains the Valider interface.
The Valider interface is used to verify the "validity" of a value, where "validity" is defined by the implementing type.
All examples are assuming the following struct:
type Example struct {
Name string
}
Where possible, implementors should use errors.Join to allow for multiple validation errors to be returned:
func (e *Example) Valid() error {
var errs []error
if e.Name == "" {
errs = append(errs, errors.New("name is empty"))
}
if len(errs) == 0 {
return nil
}
return errors.Join(errs...)
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface interface {
// Valid returns any validation errors for the value. If the value is valid, nil is returned.
//
// Where possible, implementors should use errors.Join to allow for multiple validation errors to be returned.
Valid() error
}
Interface is an interface for types that can be validated.
Click to show internal directories.
Click to hide internal directories.