validators

package
v1.0.0-beta6 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EnumTerm = ls.NewTerm(ls.LS+"validation/enumeration", false, false, ls.OverrideComposition, struct {
	EnumValidator
}{
	EnumValidator{},
})

EnumTerm is used for enumeration validator

View Source
var JsonFormatTerm = ls.NewTerm(ls.LS+"validation/json/format", false, false, ls.OverrideComposition, struct {
	JsonFormatValidator
}{
	JsonFormatValidator{},
})

JsonFormatTerm validates if the value matches one of the json format implementations

View Source
var PatternTerm = ls.NewTerm(ls.LS+"validation/pattern", false, false, ls.OverrideComposition, struct {
	PatternValidator
}{
	PatternValidator{},
})

PatternTerm validates agains a regex

View Source
var RequiredTerm = ls.NewTerm(ls.LS+"validation/required", false, false, ls.OverrideComposition, struct {
	RequiredValidator
}{
	RequiredValidator{},
})

RequiredTerm validates if a required properties exist

Functions

This section is empty.

Types

type EnumValidator

type EnumValidator struct{}

EnumValidator checks if a value is equal to one of the given options.

func (EnumValidator) Validate

func (validator EnumValidator) Validate(docNode, schemaNode ls.Node) error

Validate validates the node value if it is non-nil

func (EnumValidator) ValidateValue

func (validator EnumValidator) ValidateValue(value interface{}, options []interface{}) error

ValidateValue checks if the value is the same as one of the options.

type JsonFormatValidator

type JsonFormatValidator struct{}

JsonFormatValidator checks if the input value matches a given format

func (JsonFormatValidator) CompileTerm

func (validator JsonFormatValidator) CompileTerm(_ string, value *ls.PropertyValue) (interface{}, error)

func (JsonFormatValidator) Validate

func (validator JsonFormatValidator) Validate(docNode, schemaNode ls.Node) error

Validate validates the node value if it is non-nil

func (JsonFormatValidator) ValidateValue

func (validator JsonFormatValidator) ValidateValue(value interface{}, format string) error

ValidateValue checks if the value matches the format

type PatternValidator

type PatternValidator struct{}

PatternValidator validates a string value agains a regex

func (PatternValidator) CompileTerm

func (validator PatternValidator) CompileTerm(_ string, value *ls.PropertyValue) (interface{}, error)

Compile the pattern

func (PatternValidator) Validate

func (validator PatternValidator) Validate(docNode, schemaNode ls.Node) error

Validate validates the node value if it is non-nil

type RequiredValidator

type RequiredValidator struct{}

RequiredValidator validates if a required value exists

func (RequiredValidator) CompileTerm

func (validator RequiredValidator) CompileTerm(_ string, value *ls.PropertyValue) (interface{}, error)

Compile the required properties array

func (RequiredValidator) Validate

func (validator RequiredValidator) Validate(docNode, schemaNode ls.Node) error

Validate checks if value is nil. If value is nil and it is required, returns an error

Jump to

Keyboard shortcuts

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