Module fog_pack::validator [−][src]
Expand description
The fog-pack Validators, for building Schemas and Queries.
This submodule contains various validators, which can be transformed into the Validator
enum type for use in a Schema or a Query. Each struct acts as a constructor that can be
built into a Validator.
Validators are not used directly; instead, they should be used to build a Schema or Query, which will run them against fog-pack data.
Examples
Say we want to build a Document that acts like a file directory. We want to store the creation time of the directory, and a list of file names with associated Hashes, each of which will be the Hash of a file or directory. Let’s also assume we want a valid Unix file name, meaning “/” and NUL cannot be in the name, it cannot be longer than 255 bytes, and shouldn’t be “.” or “..”. A validator for this Document might look like:
let dir = MapValidator::new()
.req_add("created", TimeValidator::new().build())
.req_add("contents", MapValidator::new()
.keys(KeyValidator::new()
.matches(Regex::new(r"^[^/\x00]+$").unwrap())
.max_len(255)
.min_len(1)
)
.ban_add(".")
.ban_add("..")
.values(HashValidator::new().build())
.build()
)
.build();Structs
Validator for arrays.
Validator for byte sequences.
Validator for boolean values.
Validator for a DataLockbox.
This validator will only pass a
DataLockbox
value. Validation passes if:
“Enum” validator that selects a validator based on the value’s enum variant.
Validator for 32-bit floating-point values.
Validator for 64-bit floating-point values.
Validator for hashes.
Validator for a IdentityLockbox.
This validator will only pass a
IdentityLockbox
value. Validation passes if:
Validator for a cryptographic Identity.
Validator for integer values.
Special validator for the keys in a Map. Used by MapValidator.
An item in a Checklist. To complete it, find a document whose hash matches the one that was
provided alongside this item, then feed that document to the check
function of this item. If the check fails, checking should be halted and the checklist should
be discarded.
Validator for a cryptographic LockId.
Validator for a LockLockbox.
This validator will only pass a
LockLockbox
value. Validation passes if:
Validator for maps.
“Multi” validator that checks with several validators at once.
Validator for UTF-8 strings.
Validator for a cryptographic StreamId.
Validator for a StreamLockbox.
This validator will only pass a
StreamLockbox
value. Validation passes if:
Validator for timestamps.
Enums
Unicode Normalization settings.
A fog-pack Validator, for verifying the form of a fog-pack Document or Entry.