import "github.com/juju/schema"
checker.go const.go errors.go fieldmap.go lists.go maps.go numeric.go size.go strings.go time.go time_duration.go
var Omit omitOmit is a marker for FieldMap and StructFieldMap defaults parameter. If a field is not present in the map and defaults to Omit, the missing field will be ommitted from the coerced map as well.
The Coerce method of the Checker interface is called recursively when v is being validated. If err is nil, newv is used as the new value at the recursion point. If err is non-nil, v is taken as invalid and may be either ignored or error out depending on where in the schema checking process the error happened. Checkers like OneOf may continue with an alternative, for instance.
Any returns a Checker that succeeds with any input value and results in the value itself unprocessed.
Bool returns a Checker that accepts boolean values only.
Const returns a Checker that only succeeds if the input matches value exactly. The value is compared with reflect.DeepEqual.
FieldMap returns a Checker that accepts a map value with defined string keys. Every key has an independent checker associated, and processing will only succeed if all the values succeed individually. If a field fails to be processed, processing stops and returns with the underlying error.
Fields in defaults will be set to the provided value if not present in the coerced map. If the default value is schema.Omit, the missing field will be omitted from the coerced map.
The coerced output value has type map[string]interface{}.
FieldMapSet returns a Checker that accepts a map value checked against one of several FieldMap checkers. The actual checker used is the first one whose checker associated with the selector field processes the map correctly. If no checker processes the selector value correctly, an error is returned.
The coerced output value has type map[string]interface{}.
Float returns a Checker that accepts any float value, and returns the same value consistently typed as a float64.
ForceInt returns a Checker that accepts any integer or float value, and returns the same value consistently typed as an int. This is required in order to handle the interface{}/float64 type conversion performed by the JSON serializer used as part of the API infrastructure.
ForceUint returns a Checker that accepts any integer or float value, and returns the same value consistently typed as an uint64. This is required in order to handle the interface{}/float64 type conversion performed by the JSON serializer used as part of the API infrastructure. If the integer value is negative an error is raised.
Int returns a Checker that accepts any integer value, and returns the same value consistently typed as an int64.
List returns a Checker that accepts a slice value with values that are processed with the elem checker. If any element of the provided slice value fails to be processed, processing will stop and return with the obtained error.
The coerced output value has type []interface{}.
Map returns a Checker that accepts a map value. Every key and value in the map are processed with the respective checker, and if any value fails to be coerced, processing stops and returns with the underlying error.
The coerced output value has type map[interface{}]interface{}.
Nil returns a Checker that only succeeds if the input is nil. To tweak the error message, valueLabel can contain a label of the value being checked to be empty, e.g. "my special name". If valueLabel is "", "value" will be used as a label instead.
Example 1: schema.Nil("widget").Coerce(42, nil) will return an error message like `expected empty widget, got int(42)`.
Example 2: schema.Nil("").Coerce("", nil) will return an error message like `expected empty value, got string("")`.
NonEmptyString returns a Checker that only accepts non-empty strings. To tweak the error message, valueLabel can contain a label of the value being checked, e.g. "my special name". If valueLabel is "", "string" will be used as a label instead.
Example 1: schema.NonEmptyString("widget").Coerce("", nil) will return an error message like `expected non-empty widget, got string("")`.
Example 2: schema.NonEmptyString("").Coerce("", nil) will return an error message like `expected non-empty string, got string("")`.
OneOf returns a Checker that attempts to Coerce the value with each of the provided checkers. The value returned by the first checker that succeeds will be returned by the OneOf checker itself. If no checker succeeds, OneOf will return an error on coercion.
SimpleRegexp returns a checker that accepts a string value that is a valid regular expression and returns it unprocessed.
Size returns a Checker that accepts a string value, and returns the parsed string as a size in mebibytes see: https://godoc.org/github.com/juju/utils#ParseSize
StrictFieldMap returns a Checker that acts as the one returned by FieldMap, but the Checker returns an error if it encounters an unknown key.
String returns a Checker that accepts a string value only and returns it unprocessed.
StringMap returns a Checker that accepts a map value. Every key in the map must be a string, and every value in the map are processed with the provided checker. If any value fails to be coerced, processing stops and returns with the underlying error.
The coerced output value has type map[string]interface{}.
Stringified returns a checker that accepts a bool/int/float/string value and returns its string. Other value types may be supported by passing in their checkers.
Time returns a Checker that accepts a string value, and returns the parsed time.Time value. Emtpy strings are considered empty times.
TimeDuration returns a Checker that accepts a string value, and returns the parsed time.Duration value. Emtpy strings are considered empty time.Duration
URL returns a Checker that accepts a string value that must be parseable as a URL, and returns a *net.URL.
UUID returns a Checker that accepts a string value only and returns it unprocessed.
Uint returns a Checker that accepts any integer or unsigned value, and returns the same value consistently typed as an uint64. If the integer value is negative an error is raised.
Package schema imports 8 packages (graph) and is imported by 640 packages. Updated 2016-09-19. Refresh now. Tools for package owners.