Documentation ¶
Index ¶
- Variables
- func AppendValidationErrorDot(err error, selector string) error
- func AppendValidationErrorIndex(err error, selector string) error
- func ReportState(v any) string
- func UndCheck(s any) error
- func UndValidate(s any) error
- type ElasticLike
- type OptionLike
- type UndChecker
- type UndLike
- type UndValidator
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMultipleOption would be returned by UndValidate and UndCheck // if input's `und` struct tags have multiple mutually exclusive options. ErrMultipleOption = undtag.ErrMultipleOption // ErrUnknownOption is an error value which will be returned by UndValidate and UndCheck // if an input has unknown options in `und` struct tag. ErrUnknownOption = undtag.ErrUnknownOption // ErrMalformedLen is an error which will be returned by UndValidate and UndCheck // if an input has malformed len option in `und` struct tag. ErrMalformedLen = undtag.ErrMalformedLen // ErrMalformedLen is an error which will be returned by UndValidate and UndCheck // if an input has malformed values option in `und` struct tag. ErrMalformedValues = undtag.ErrMalformedValues )
var ( // ErrNotStruct would be returned by UndValidate and UndCheck // if input is not a struct nor a pointer to a struct. ErrNotStruct = errors.New("not struct") )
Functions ¶
func ReportState ¶
func UndCheck ¶
UndCheck checks whether s is correctly configured with `und` struct tag option without validating it.
func UndValidate ¶
UndValidate validates whether s is compliant to the constraint placed by `und` struct tag.
UndValidate only accepts struct or pointer to struct.
Only fields whose struct tag contains `und`, and whose type is implementor of OptionLike, UndLike, ElasticLike, or array, slice, map whose value type are one of implementor, are validated.
Types ¶
type ElasticLike ¶
type ElasticLike = undtag.ElasticLike
type OptionLike ¶
type OptionLike = undtag.OptionLike
type UndChecker ¶
type UndChecker interface {
UndCheck() error
}
UndChecker wraps the UndCheck method which is expected to be implemented on data container types like und.Und[T] and option.Option[T], etc.
UndCheck must checks if its internal data type conforms the constraint which UndValidate or UndCheck would checks.
type UndValidator ¶
type UndValidator interface {
UndValidate() error
}
UndValidator wraps the UndValidate method.
UndValidate method is implemented on data container types, und.Und[T] and option.Option[T], etc. It only validates its underlying T's compliance for constraints placed by `und` struct tag options.
type ValidationError ¶
type ValidationError struct {
// contains filtered or unexported fields
}
func NewValidationError ¶
func NewValidationError(err error) *ValidationError
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
func (*ValidationError) Pointer ¶
func (e *ValidationError) Pointer() string
Pointer returns rfc6901 compliant json pointer
func (*ValidationError) Unwrap ¶
func (e *ValidationError) Unwrap() error