playvalidator

package
v0.30.106 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 11 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Feature

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

Types

type Constraints added in v0.30.80

type Constraints map[string]string

Constraints express the validation rules without depending on validation struct tags.

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 (i *Installer) DependsOn() []setup.Feature

func (*Installer) Install

func (i *Installer) Install(b *setup.Builder) error

func (*Installer) UseTranslator

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

func (*Installer) Validator

func (i *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 Constraints
}

TypeRules express the validation Constraints for a type.

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

type Validates4 added in v0.30.32

type Validates4[T any] struct {
	Validator
}

Validates4 handles validation for a specific type.

func (*Validates4[T]) Validate4 added in v0.30.69

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

type Validates5 added in v0.30.32

type Validates5[T any] struct {
	Validator
}

Validates5 handles validation for a specific type.

func (*Validates5[T]) Validate5 added in v0.30.69

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

type Validates6 added in v0.30.69

type Validates6[T any] struct {
	Validator
}

Validates6 handles validation for a specific type.

func (*Validates6[T]) Validate6 added in v0.30.69

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

type Validates7 added in v0.30.69

type Validates7[T any] struct {
	Validator
}

Validates7 handles validation for a specific type.

func (*Validates7[T]) Validate7 added in v0.30.69

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

type Validates8 added in v0.30.69

type Validates8[T any] struct {
	Validator
}

Validates8 handles validation for a specific type.

func (*Validates8[T]) Validate8 added in v0.30.69

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

type Validates9 added in v0.30.69

type Validates9[T any] struct {
	Validator
}

Validates9 handles validation for a specific type.

func (*Validates9[T]) Validate9 added in v0.30.69

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

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