playvalidator

package
v0.30.53 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: MIT Imports: 10 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Feature

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

Types

type Installer

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

Installer integrates validation support for the go playground validator. https://github.com/go-playground/validator/

func (*Installer) DependsOn

func (v *Installer) DependsOn() []miruken.Feature

func (*Installer) Install

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

func (*Installer) UseTranslator

func (v *Installer) UseTranslator(translator ut.Translator)

func (*Installer) Validator

func (v *Installer) Validator() *play.Validate

type Rules

type Rules []TypeRules

Rules express the validation constraints for a set of types.

type TypeRules added in v0.30.27

type TypeRules struct {
	Type        any
	Constraints map[string]string
}

TypeRules express the validation constraints for a type without depending on validation struct tags.

func Type added in v0.30.27

func Type[T any](constraints map[string]string) TypeRules

Type is a helper function to define the constraints for a type.

type Validates added in v0.30.32

type Validates[T any] struct {
	Validator
}

Validates handles validation for a specific type. We duplicate the definitions below to allow multiple validations for a single type. We take advantage of GO composition to inject a validation handle method. Methods are only composed if it appears once. Therefore, we duplicate the validators and define a unique method i.e. Validate1, Validate2, ...

func (*Validates[T]) Validate added in v0.30.32

func (v *Validates[T]) Validate(
	validate *validates.It, t T,
) miruken.HandleResult

type Validates1 added in v0.30.32

type Validates1[T any] struct {
	Validator
}

Validates1 handles validation for a specific type.

func (*Validates1[T]) Validate1 added in v0.30.32

func (v *Validates1[T]) Validate1(
	validate *validates.It, t T,
) miruken.HandleResult

type Validates2 added in v0.30.32

type Validates2[T any] struct {
	Validator
}

Validates2 handles validation for a specific type.

func (*Validates2[T]) Validate2 added in v0.30.32

func (v *Validates2[T]) Validate2(
	validate *validates.It, t T,
) miruken.HandleResult

type Validates3 added in v0.30.32

type Validates3[T any] struct {
	Validator
}

Validates3 handles validation for a specific type.

func (*Validates3[T]) Validate3 added in v0.30.32

func (v *Validates3[T]) Validate3(
	validate *validates.It, t T,
) miruken.HandleResult

func (*Validates3[T]) Validate4 added in v0.30.32

func (v *Validates3[T]) Validate4(
	validate *validates.It, t T,
) miruken.HandleResult

func (*Validates3[T]) Validate5 added in v0.30.32

func (v *Validates3[T]) Validate5(
	validate *validates.It, t T,
) miruken.HandleResult

type Validates4 added in v0.30.32

type Validates4[T any] struct {
	Validator
}

Validates4 handles validation for a specific type.

type Validates5 added in v0.30.32

type Validates5[T any] struct {
	Validator
}

Validates5 handles validation for a specific type.

type Validator

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

Validator provides core validation behavior.

func (*Validator) Constructor

func (v *Validator) Constructor(
	validate *play.Validate,
	_ *struct{ args.Optional }, translator ut.Translator,
)

func (*Validator) Validate

func (v *Validator) Validate(
	target any,
	outcome *validates.Outcome,
) miruken.HandleResult

func (*Validator) ValidateAndStop

func (v *Validator) ValidateAndStop(
	target any,
	outcome *validates.Outcome,
) miruken.HandleResult

func (*Validator) WithRules added in v0.30.29

func (v *Validator) WithRules(
	rules Rules,
	configure func(*play.Validate) error,
	translator ut.Translator,
) error

Jump to

Keyboard shortcuts

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