Skip to main content

Module builders

Module builders 

Source
Expand description

The builders: functions that take a spec and return a node with the builder’s rule applied, and the same as methods on a node so they chain.

A builder given a wrong argument returns a node that accepts nothing and says why at validation, since a Rust builder cannot throw as the canonical one does; a chain method on such an argument turns its node into that fault.

Structs§

ReferOptions
refer options.
RenameOptions
rename options.

Enums§

TypeRef
What type_ takes its kind from.

Functions§

above
A strict lower bound on value, or length.
after
A custom validator run after the structural check.
all
The value must satisfy every shape.
any
An optional Any, the node a builder with no spec starts from.
before
A custom validator run before the structural check.
below
A strict upper bound on value, or length.
buildize
A spec as a node: what every builder starts from.
catch
Whatever fails inside is replaced with the fallback, raising nothing.
check
A custom check, run before the structural check.
check_re
A regexp check: the value must be a string matching it. A failure reads check "/re/" failed.
child
The shape of every unknown object value, or of every array element.
closed
An object rejects keys it does not declare; a single-shape array becomes a tuple of one.
coerce
The value is converted to the node’s kind where the conversion is unambiguous, before the type check.
date_time
A strict ISO 8601 date-time string.
default
Optional, with an explicit default. The node is the spec’s, so an object or array shape keeps its children; an untyped spec takes the default’s kind.
default_of
A default with no spec: the node takes the default’s kind.
define
Name the node so a later refer can substitute it.
describe
A description, read back from the node’s meta.
email
A string in email address form.
empty
The empty string is allowed. Untyped when bare: empty(any()) allows the empty string without also demanding a string.
exact
The value must equal one of the literals.
fault
A Fault message overriding the structural text.
func
A function-typed value. A builder, not a type token, so it does not require a value of itself.
ignore
Like skip, and a value that fails is dropped with its errors.
ip
An IPv4 or IPv6 address.
ipv4
A dotted-quad IPv4 address.
ipv6
An IPv6 address in RFC 4291 text form.
key
The value is replaced with the key of the property it sits under.
key_args
key from raw arguments: a numeric argument is the depth, a string the separator, as the string form of a spec supplies them.
key_depth
The value is replaced with the path depth levels up, as an array.
key_join
The value is replaced with the path depth levels up, joined by sep.
len
An exact value, or length.
max
A maximum value, or length.
min
A minimum value, or length.
never
A node that accepts nothing.
nullable
An explicit null is accepted as the value.
one
The value must satisfy exactly one of the shapes.
open
An object accepts keys it does not declare.
optional
The value may be absent; the default is injected.
refer
Substitute the named node at validation time.
refer_with
refer with options.
rename
Rename the property after validation. For object children only.
rename_with
rename with options.
required
The value must be present.
rest
The shape of the array elements past the tuple positions.
skip
Optional, and an absent value leaves the key out.
some
The value must satisfy at least one of the shapes.
transform
A valid value is replaced with a function of it.
type_
The kind the node asserts, given a kind, a token, a kind name or a node to take it from.
url
An absolute URL.
uuid
A UUID in 8-4-4-4-12 hex form.