owl

package module
v1.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 5 Imported by: 0

README

a zero dependency performant validation library

Rules

Name Description Status
required not nil or zero value
default default value
enum one of a set of options

String

Name Description Status
pattern match regular expression
format match format
min min length
max max length

Numeric

Name Description Status
min minimum
max maximum

Formats

Name Status
date_time
email
ipv4
ipv6
uri
uuid

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFormat

func AddFormat(name string, formatter Formatter)

func AddRule

func AddRule(name string, rule Rule)

func New

func New() *owl

Types

type Error

type Error struct {
	Path    string `json:"path"`
	Keyword string `json:"keyword"`
	Message string `json:"message"`
}

func Validate

func Validate(v any) []Error

func (Error) Error

func (self Error) Error() string

type Formatter

type Formatter func(string) error

type Rule

type Rule interface {
	Select(
		schema map[string]string,
		parent reflect.Value,
		value reflect.Value,
	) bool

	Validate(
		schema map[string]string,
		parent reflect.Value,

		value reflect.Value,
	) (reflect.Value, []error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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