validate

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 4 Imported by: 0

README

internal/validate

err := validate.NonEmpty("id", "doc-1")
err = validate.Positive("limit", 10)

internal/validate contains small validation helpers shared by public packages.

It does not own product validation policy, user-facing messages, or schema validation frameworks.

Documentation

Overview

Package validate provides small validation helpers for primitive packages. Product validation policy, schema frameworks, and user-facing messages stay with callers.

Package validate provides small validation helpers for primitive packages.

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// ErrRequired reports a missing required value.
	ErrRequired = errors.New("required")
	// ErrInvalid reports a value outside its valid semantic space.
	ErrInvalid = errors.New("invalid")
)

Functions

func Equal

func Equal[T comparable](field string, got, want T) error

Equal returns an error when got and want differ.

func IsNil added in v0.9.0

func IsNil(value any) bool

IsNil reports whether value is nil, including an interface containing a typed nil value of a nilable kind.

func NonEmpty

func NonEmpty(field, value string) error

NonEmpty returns an error when value is empty after trimming whitespace.

Example
package main

import (
	"fmt"

	"github.com/dotcommander/reliquary/internal/validate"
)

func main() {
	err := validate.NonEmpty("id", "doc-1")
	fmt.Println(err == nil)
}
Output:
true

func Positive

func Positive(field string, value int) error

Positive returns an error when value is not greater than zero.

Types

This section is empty.

Jump to

Keyboard shortcuts

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