Module fog_pack::validator [−][src]
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
| ArrayValidator | Validator for arrays. |
| BinValidator | Validator for byte sequences. |
| BoolValidator | Validator for boolean values. |
| DataChecklist | |
| DataLockboxValidator | Validator for a |
| EnumValidator | “Enum” validator that selects a validator based on the value’s enum variant. |
| F32Validator | Validator for 32-bit floating-point values. |
| F64Validator | Validator for 64-bit floating-point values. |
| HashValidator | Validator for hashes. |
| IdentityLockboxValidator | Validator for a |
| IdentityValidator | Validator for a cryptographic |
| IntValidator | Validator for integer values. |
| KeyValidator | Special validator for the keys in a Map. Used by MapValidator. |
| ListItem | 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 |
| LockIdValidator | Validator for a cryptographic |
| LockLockboxValidator | Validator for a |
| MapValidator | Validator for maps. |
| MultiValidator | “Multi” validator that checks with several validators at once. |
| StrValidator | Validator for UTF-8 strings. |
| StreamIdValidator | Validator for a cryptographic |
| StreamLockboxValidator | Validator for a |
| TimeValidator | Validator for timestamps. |
Enums
| Normalize | Unicode Normalization settings. |
| Validator | A fog-pack Validator, for verifying the form of a fog-pack Document or Entry. |