Documentation ¶
Overview ¶
Package validation provides a helper for performing config validations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct { Logger logging.Logger // logs errors as they appear // contains filtered or unexported fields }
Context is an accumulator for validation errors.
It is passed to a function that does config validation. Such function may validate a bunch of files (using SetFile to indicate which one is processed now). Each file may have some internal nested structure. The logical path inside this structure is captured through Enter and Exit calls.
func (*Context) Enter ¶
Enter descends into a sub-element when validating a nested structure.
Useful for defining context. A current path of elements shows up in validation messages.
The reverse is Exit.
func (*Context) Error ¶
Error records a validation error.
func (*Context) Exit ¶
func (v *Context) Exit()
Exit pops the current element we are visiting from the stack.
This is the reverse of Enter. Each Enter must have corresponding Exit. Use functions and defers to ensure this, if it's otherwise hard to track.
func (*Context) Finalize ¶
Finalize returns *Error if some validation errors were recorded.
Returns nil otherwise.
type Error ¶
type Error struct { // Errors is a list of individual validation errors. // // Each one is annotated with "file" string and a logical path pointing to // the element that contains the error. It is provided as a slice of strings // in "element" annotation. Errors errors.MultiError }
Error is an error with details of failed validation.
Returned by Context.Finalize().