Struct fog_pack::validator::HashValidator [−][src]
Validator for hashes.
This validator type will only pass hash values. Validation passes if:
- If the
inlist is not empty, the hash must be among the hashes in the list. - The hash must not be among the hashes in the
ninlist. - If
linkhas a validator, the data in the Document referred to by the hash must pass that validator. - If the
schemalist is not empty, the Document referred to by the hash must use one of the schemas listed. Anullvalue on the list means the schema containing this validator is also accepted.
The link and schema checks only apply when validating Entries, not Documents.
Hash validators are unique in that they do not always complete validation after examining a
single value. If used for checking an Entry, they can require an additional Document for
validation. For this reason, completing validation of an Entry requires completing a
DataChecklist. See the Schema documentation for more
details.
Defaults
Fields that aren’t specified for the validator use their defaults instead. The defaults for each field are:
- comment: “”
- link: None
- schema: empty
- in_list: empty
- nin_list: empty
- query: false
- link_ok: false
- schema_ok: false
Query Checking
Queries for hashes are only allowed to use non-default values for each field if the corresponding query permission is set in the schema’s validator:
- query:
inandninlists - link_ok:
link - schema_ok:
schema
In addition, if there is a validator for link, it is validated against the schema validator’s
link validator.
Fields
comment: StringAn optional comment explaining the validator.
link: Option<Box<Validator>>An optional validator used to validate the data in a Document linked to by the hash. If not present, any data is allowed in the linked Document.
schema: Vec<Option<Hash>>A list of allowed schemas for a Document linked to by the hash. A None value refers to
the validator’s containing schema. For validators used in queries, None is skipped. If
empty, this list is ignored during checking.
in_list: Vec<Hash>A vector of specific allowed values, stored under the in field. If empty, this vector is not checked against.
nin_list: Vec<Hash>A vector of specific unallowed values, stored under the nin field.
query: boolIf true, queries against matching spots may have values in the in or nin lists.
link_ok: boolIf true, queries against matching spots may have a validator in link.
schema_ok: boolIf true, queries against matching spots may have values in the schema list.
Implementations
impl HashValidator[src]
pub fn new() -> Self[src]
Make a new validator with the default configuration.
pub fn link(self, link: Validator) -> Self[src]
Set the link validator.
pub fn schema_add(self, add: impl Into<Hash>) -> Self[src]
Add a Hash to the schema list.
pub fn schema_self(self) -> Self[src]
Allow referred-to documents to use this validator’s containing schema.
pub fn in_add(self, add: impl Into<Hash>) -> Self[src]
Add a value to the in list.
pub fn nin_add(self, add: impl Into<Hash>) -> Self[src]
Add a value to the nin list.
pub fn query(self, query: bool) -> Self[src]
Set whether or not queries can use the in and nin lists.
pub fn link_ok(self, link_ok: bool) -> Self[src]
Set whether or not queries can use link.
pub fn schema_ok(self, schema_ok: bool) -> Self[src]
Set whether or not queries can use schema.
pub fn build(self) -> Validator[src]
Build this into a Validator enum.
Trait Implementations
impl Clone for HashValidator[src]
fn clone(&self) -> HashValidator[src]
pub fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Debug for HashValidator[src]
impl Default for HashValidator[src]
impl<'de> Deserialize<'de> for HashValidator where
HashValidator: Default, [src]
HashValidator: Default,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, [src]
__D: Deserializer<'de>,
impl PartialEq<HashValidator> for HashValidator[src]
fn eq(&self, other: &HashValidator) -> bool[src]
fn ne(&self, other: &HashValidator) -> bool[src]
impl Serialize for HashValidator[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer, [src]
__S: Serializer,
impl StructuralPartialEq for HashValidator[src]
Auto Trait Implementations
impl RefUnwindSafe for HashValidator
impl Send for HashValidator
impl Sync for HashValidator
impl Unpin for HashValidator
impl UnwindSafe for HashValidator
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>, [src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,