golidate

package module
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Condition

type Condition func(value any) bool

type Dictionary

type Dictionary map[string]Entry

type Entry

type Entry func(dictionary Dictionary, result Result) Result

type Formatter

type Formatter func(string) string

type Grouped

type Grouped map[string]Results

func (Grouped) Messages

func (grouped Grouped) Messages(formatters ...Formatter) map[string][]string

type Metadata

type Metadata map[string]any

type OnRename

type OnRename func(result Result)

func OnRenameMany

func OnRenameMany(key string) OnRename

func OnRenameSingle

func OnRenameSingle(key string) OnRename

type Pending

type Pending struct {
	// contains filtered or unexported fields
}

func Self added in v0.10.0

func Self(value any) Pending

func Value

func Value(value any) Pending

func (Pending) AppendRules

func (pending Pending) AppendRules(rules ...Rule) Pending

func (Pending) Name

func (pending Pending) Name(attribute string) Pending

func (Pending) Rules

func (pending Pending) Rules(rules ...Rule) Pending

func (Pending) Validate

func (pending Pending) Validate(ctx context.Context) Results

type Result

type Result struct {
	Attribute string   `json:"attribute"`
	Value     any      `json:"value"`
	Code      string   `json:"code"`
	Message   string   `json:"message"`
	Metadata  Metadata `json:"metadata"`
	// contains filtered or unexported fields
}

func Fail

func Fail(value any, code string) Result

func Pass

func Pass(value any, code string) Result

func Uncertain

func Uncertain(value any, code string) Result

func (Result) Conditions

func (result Result) Conditions(conditions ...Condition) Result

func (Result) Fail

func (result Result) Fail() Result

func (Result) Name

func (result Result) Name(attribute string) Result

func (Result) OnRename

func (result Result) OnRename(callback OnRename) Result

func (Result) Pass

func (result Result) Pass() Result

func (Result) Passes

func (result Result) Passes() bool

func (Result) PassesAll

func (result Result) PassesAll() bool

func (Result) PassesChilds

func (result Result) PassesChilds() bool

func (Result) Results

func (result Result) Results(name string) Results

func (Result) Translate

func (result Result) Translate(dictionaries ...Dictionary) Result

func (Result) When

func (result Result) When(condition bool) Result

func (Result) With

func (result Result) With(key string, value any) Result

func (Result) WithChild

func (result Result) WithChild(child Result) Result

func (Result) WithMetadata

func (result Result) WithMetadata(metadata Metadata) Result

func (Result) WithMetadataMerged

func (result Result) WithMetadataMerged(metadata Metadata) Result

func (Result) WithPrefixedChild added in v0.9.0

func (result Result) WithPrefixedChild(child Result) Result

type Results

type Results []Result

func Validate

func Validate(ctx context.Context, pendings ...Pending) Results

func (Results) Failed

func (results Results) Failed() Results

func (Results) Group

func (results Results) Group() Grouped

func (Results) Has added in v0.3.0

func (results Results) Has(attribute string) bool

func (Results) Messages

func (results Results) Messages(formatters ...Formatter) []string

func (Results) Passed

func (results Results) Passed() Results

func (Results) PassesAll

func (results Results) PassesAll() bool

func (Results) PassesAny

func (results Results) PassesAny() bool

func (Results) Prefixed

func (results Results) Prefixed(prefix string) Results

func (Results) Translate

func (results Results) Translate(dictionaries ...Dictionary) Results

type Rule

type Rule func(value any) Result

func (Rule) Code

func (rule Rule) Code(code string) Rule

func (Rule) Conditions

func (rule Rule) Conditions(conditions ...Condition) Rule

func (Rule) Message added in v0.6.0

func (rule Rule) Message(message string) Rule

func (Rule) Rename added in v0.6.0

func (rule Rule) Rename(code string) Rule

func (Rule) When

func (rule Rule) When(condition bool) Rule

func (Rule) With

func (rule Rule) With(key string, val any) Rule

func (Rule) WithMetadata

func (rule Rule) WithMetadata(metadata Metadata) Rule

func (Rule) WithMetadataMerged

func (rule Rule) WithMetadataMerged(metadata Metadata) Rule

type Rules

type Rules []Rule

type Validator added in v0.4.0

type Validator interface {
	Validate(ctx context.Context) Results
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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