llresult

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: Apache-2.0 Imports: 2 Imported by: 59

Documentation

Index

Constants

This section is empty.

Variables

View Source
var KeyMissingVR = ValueResult{
	false,
	"expected this key to be present",
}

KeyMissingVR is emitted when a key was expected, but was not present.

View Source
var StrictFailureVR = ValueResult{
	false,
	"unexpected field encountered during strict validation",
}

StrictFailureVR is emitted when Strict() is used, and an unexpected field is found.

View Source
var ValidVR = ValueResult{true, "is valid"}

ValidVR is a convenience value for Valid results.

Functions

This section is empty.

Types

type Results

type Results struct {
	Fields map[string][]ValueResult
	Valid  bool
}

Results the results of executing a schema. They are a flattened map (using dotted paths) of all the values ValueResult representing the results of the IsDefs.

func KeyMissingResult

func KeyMissingResult(path llpath.Path) *Results

KeyMissingResult is emitted when a key was expected, but was not present.

func NewResults

func NewResults() *Results

NewResults creates a new Results object.

func SimpleResult

func SimpleResult(path llpath.Path, valid bool, msg string, args ...interface{}) *Results

SimpleResult provides a convenient and simple method for creating a *Results object for a single validation. It's a very common way for validators to return a *Results object, and is generally simpler than using SingleResult.

func SingleResult

func SingleResult(path llpath.Path, result ValueResult) *Results

SingleResult returns a *Results object with a single validated value at the given Path using the providedValueResult as its sole validation.

func StrictFailureResult

func StrictFailureResult(path llpath.Path) *Results

StrictFailureResult is emitted when Strict() is used, and an unexpected field is found.

func ValidResult

func ValidResult(p llpath.Path) *Results

ValidResult is a convenience value for Valid results.

func (*Results) DetailedErrors

func (r *Results) DetailedErrors() *Results

DetailedErrors returns a new Results object consisting only of error data.

func (Results) EachResult

func (r Results) EachResult(f func(llpath.Path, ValueResult) bool)

EachResult executes the given callback once per Value result. The provided callback can return true to keep iterating, or false to stop.

func (Results) Errors

func (r Results) Errors() []error

Errors returns a list of error objects, one per failed value validation.

func (*Results) Merge

func (r *Results) Merge(other *Results)

Merge combines multiple *Results sets together.

func (*Results) MergeUnderPrefix

func (r *Results) MergeUnderPrefix(prefix llpath.Path, other *Results)

MergeUnderPrefix merges the given results at the path specified by the given prefix.

func (*Results) Record

func (r *Results) Record(p llpath.Path, result ValueResult)

Record records a single path result to this instance.

type ValueResult

type ValueResult struct {
	Valid   bool
	Message string // Reason this is invalid
}

ValueResult represents the result of checking a leaf value.

type ValueResultError

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

ValueResultError is used to represent an error validating an individual value.

func (ValueResultError) Error

func (vre ValueResultError) Error() string

Error returns the error that occurred during validation with its context included.

Jump to

Keyboard shortcuts

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