validate

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Feature

func Feature(
	config ...func(installer *Installer),
) miruken.Feature

Feature creates and configures validation support.

func Output

func Output(installer *Installer)

func Rules

func Rules(groups ...any) miruken.BindingConstraint

Rules builds a validation Group constraint.

Types

type ApiMapping

type ApiMapping struct{}

ApiMapping maps validation errors for api transport.

func (*ApiMapping) ForApi

func (m *ApiMapping) ForApi(
	_ *struct {
		miruken.Maps
		miruken.Format `to:"api:error"`
	}, outcome *Outcome,
) (ao []ApiOutcome)

func (*ApiMapping) FromApi

func (m *ApiMapping) FromApi(
	_ *struct {
		miruken.Maps
		miruken.Format `from:"api:error"`
	}, apiOutcome []*ApiOutcome,
) (*Outcome, error)

func (*ApiMapping) New added in v0.12.0

func (m *ApiMapping) New(
	_ *struct {
		miruken.Creates `key:"validate.ApiOutcome"`
	},
) *ApiOutcome

type ApiOutcome

type ApiOutcome struct {
	PropertyName string
	Errors       []string
	Nested       []ApiOutcome
}

ApiOutcome transports Outcome information over an api.

type Builder

type Builder struct {
	miruken.CallbackBuilder
	// contains filtered or unexported fields
}

Builder builds Validates callbacks.

func (*Builder) NewValidates

func (b *Builder) NewValidates() *Validates

func (*Builder) Target

func (b *Builder) Target(
	target any,
) *Builder

type Group

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

Group marks a set of related validations.

func (*Group) InitWithTag

func (g *Group) InitWithTag(tag reflect.StructTag) error

func (*Group) Matches

func (g *Group) Matches(metadata *miruken.BindingMetadata) bool

func (*Group) Merge

func (g *Group) Merge(constraint miruken.BindingConstraint) bool

func (*Group) Require

func (g *Group) Require(metadata *miruken.BindingMetadata)

func (*Group) Required added in v0.12.0

func (g *Group) Required() bool

type Installer

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

Installer configures validation support.

func (*Installer) Install

func (v *Installer) Install(setup *miruken.SetupBuilder) error

func (*Installer) ValidateOutput

func (v *Installer) ValidateOutput()

type Outcome

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

Outcome captures structured validation errors.

func Validate

func Validate(
	handler miruken.Handler,
	target any,
	constraints ...any,
) (o *Outcome, po *promise.Promise[*Outcome], err error)

Validate initiates validation of the `target`.

func (*Outcome) AddError

func (v *Outcome) AddError(
	path string,
	err error,
)

func (*Outcome) Error

func (v *Outcome) Error() string

func (*Outcome) FieldErrors

func (v *Outcome) FieldErrors(
	path string,
) []error

func (*Outcome) Fields

func (v *Outcome) Fields() []string

func (*Outcome) Path

func (v *Outcome) Path(
	path string,
) *Outcome

func (*Outcome) RequirePath

func (v *Outcome) RequirePath(
	path string,
) *Outcome

func (*Outcome) Valid

func (v *Outcome) Valid() bool

type Provider

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

Provider is a FilterProvider for validation.

func (*Provider) AppliesTo

func (v *Provider) AppliesTo(
	callback miruken.Callback,
) bool

func (*Provider) Filters

func (v *Provider) Filters(
	binding miruken.Binding,
	callback any,
	composer miruken.Handler,
) ([]miruken.Filter, error)

func (*Provider) InitWithTag

func (v *Provider) InitWithTag(tag reflect.StructTag) error

func (*Provider) Required

func (v *Provider) Required() bool

type Validates

type Validates struct {
	miruken.CallbackBase
	// contains filtered or unexported fields
}

Validates callbacks contravariantly.

func (*Validates) Dispatch

func (v *Validates) Dispatch(
	handler any,
	greedy bool,
	composer miruken.Handler,
) miruken.HandleResult

func (*Validates) Groups

func (v *Validates) Groups() []any

func (*Validates) InGroup

func (v *Validates) InGroup(group any) bool

func (*Validates) Key

func (v *Validates) Key() any

func (*Validates) Outcome

func (v *Validates) Outcome() *Outcome

func (*Validates) Policy

func (v *Validates) Policy() miruken.Policy

func (*Validates) Source

func (v *Validates) Source() any

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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