check

package
v0.0.0-...-f4bcde8 Latest Latest
Warning

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

Go to latest
Published: May 13, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package check is a collection of functions that assert various facts about the strings.

Package check is a collection of functions that can be used for checking single values. These functions are so simple there are many useful ways they can be generated and some common cases are provided here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fail

func Fail(_ string) error

Fail check will always return an error.

func Pass

func Pass(_ string) error

Pass is a path check that will always pass, never returns an error.

Types

type Func

type Func func(contents string) error

Func is a check function, defined here as a simple function that takes a string and returns an error explaining why the check failed or nil if the input passed the check.

func And

func And(funcs ...Func) Func

And combines multiple check Func's into a single one where all must pass. Short circuits on first failure.

func Equality

func Equality(expected string) Func

Equality dose a string equality check on the found value. This performs no deserialization of the value, this means you may need to include qoutes for strings.

func Invert

func Invert(next Func) Func

Invert the output of the given Func, if it returned nil then return an error, if it returned error return nil.

func Or

func Or(funcs ...Func) Func

Or combines multiple check Func's into a single one where any one must pass, the rest may fail. Short circuits on first success.

func RegexMatch

func RegexMatch(expr string) Func

RegexMatch compiles the given regex and returns a patcheck Func that asserts values match the expression.

func Transform

func Transform(f func(string) string, next Func) Func

Transform make it easy to alter a value before passing it to the next pathcheck Func. This might be useful for stripping whitespace or normalizing case. The func f will be run each time the Func next is evaluated.

Jump to

Keyboard shortcuts

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