types

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package types defines validation error types used across the abyss project.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseHumanError added in v0.0.3

type BaseHumanError struct {
	Message string
	Err     error
}

BaseHumanError is the most basic version of HumanError, and simply embeds a static human error message inside it.

func NewHumanError added in v0.0.3

func NewHumanError(err error, messages ...string) *BaseHumanError

NewHumanError wraps err with a human-readable message.

func (*BaseHumanError) Error added in v0.0.3

func (e *BaseHumanError) Error() string

Error returns the underlying error message.

func (*BaseHumanError) HumanError added in v0.0.3

func (e *BaseHumanError) HumanError() string

HumanError returns the human-readable message.

type HumanError added in v0.0.3

type HumanError interface {
	error
	HumanError() string
}

HumanError is an extension of the built-in error that also bundles a more human-readable variant of the message. I.e. where the normal error might say "failed to open file ...: $error message", HumanError would contain something more helpful like "failed while trying to read your configuration file. Make sure it exists and has correct permissions."

type ValidationError

type ValidationError struct {
	// The name of the type that failed validation.  Usually the name of a struct.
	Type string

	// The name of the field that failed to validate.
	Field string

	// A human-readable explanation of why validation failed, like "should be non-zero"
	Reason string
}

ValidationError is a custom error type that embeds information about a failed validation, such as the field that was invalid.

func NewValidationError

func NewValidationError(from any, field string, reason string) *ValidationError

NewValidationError constructs a ValidationError describing the given field and reason for the failure on the provided value.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error implements the error interface.

type Validator

type Validator interface {
	Validate() error
}

Validator is an object that can be validated and returns errors if the data within the object is invalid.

Jump to

Keyboard shortcuts

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