[−][src]Derive Macro verify::Verify
#[derive(Verify)] { // Attributes available to this derive: #[verify] }
Macro for deriving Verify.
Attributes
All options are set by the verify
attribute.
Container Attributes
serde
Use Serde for validation.
Options:
- spans (optional): The name of the type that provides spans, it must implement Spans. By default KeySpans is used.
Example:
ⓘThis example is not tested
#[verify(serde(spans = "KeySpans"))] pub struct Example { ... }
schemars
Use Schemars schema for validation.
Works only if the type implements Serialize and JsonSchema.
It also needs the serde
to be enabled.
Example:
ⓘThis example is not tested
#[verify(schemars, serde)] pub struct Example { ... }
verifier
Provide what verifier to use.
Options:
- name: The name of the verifier type.
- create (optional): How the verifier should be constructed, Default is used if not set.
- error (optional): The error type of the verifier, it might be needed when there are ambiguous complex generics that cannot be guessed by the macro.
Example:
With name only:
ⓘThis example is not tested
#[verify(verifier = "ExampleVerifier")] pub struct Example { ... }
Or with options:
ⓘThis example is not tested
#[verify( verifier( name = "verifiers::ExampleVerifier", create = "verifiers::get_a_new_verifier(self.config())" ) )] pub struct Example { ... }
Field Attributes
Field attributes are ignored for now.