Documentation ¶
Index ¶
- Variables
- type Results
- func KeyMissingResult(path llpath.Path) *Results
- func NewResults() *Results
- func SimpleResult(path llpath.Path, valid bool, msg string, args ...interface{}) *Results
- func SingleResult(path llpath.Path, result ValueResult) *Results
- func StrictFailureResult(path llpath.Path) *Results
- func ValidResult(p llpath.Path) *Results
- func (r *Results) DetailedErrors() *Results
- func (r Results) EachResult(f func(llpath.Path, ValueResult) bool)
- func (r Results) Errors() []error
- func (r *Results) Merge(other *Results)
- func (r *Results) MergeUnderPrefix(prefix llpath.Path, other *Results)
- func (r *Results) Record(p llpath.Path, result ValueResult)
- type ValueResult
- type ValueResultError
Constants ¶
This section is empty.
Variables ¶
var KeyMissingVR = ValueResult{ false, "expected this key to be present", }
KeyMissingVR is emitted when a key was expected, but was not present.
var StrictFailureVR = ValueResult{ false, "unexpected field encountered during strict validation", }
StrictFailureVR is emitted when Strict() is used, and an unexpected field is found.
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 ¶
KeyMissingResult is emitted when a key was expected, but was not present.
func SimpleResult ¶
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 ¶
StrictFailureResult is emitted when Strict() is used, and an unexpected field is found.
func ValidResult ¶
ValidResult is a convenience value for Valid results.
func (*Results) DetailedErrors ¶
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) MergeUnderPrefix ¶
MergeUnderPrefix merges the given results at the path specified by the given prefix.
type ValueResult ¶
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.