valid

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: CC0-1.0 Imports: 0 Imported by: 0

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.

Jump to

Keyboard shortcuts

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