Trait async_graphql::validators::InputValueValidator [−][src]
pub trait InputValueValidator where
Self: Sync + Send, { fn is_valid(&self, value: &Value) -> Result<(), String>; }
Expand description
Input value validator
You can create your own input value validator by implementing this trait.
Examples
use async_graphql::*; use async_graphql::validators::{Email, MAC, IntRange}; struct QueryRoot; #[Object] impl QueryRoot { // Input is email address async fn value1(&self, #[graphql(validator(Email))] email: String) -> i32 { unimplemented!() } // Input is email or MAC address async fn value2(&self, #[graphql(validator(or(Email, MAC(colon = "false"))))] email_or_mac: String) -> i32 { unimplemented!() } // Input is integer between 100 and 200 async fn value3(&self, #[graphql(validator(IntRange(min = "100", max = "200")))] value: i32) -> i32 { unimplemented!() } }
Required methods
Implementors
impl<A, B> InputValueValidator for And<A, B> where
A: InputValueValidator,
B: InputValueValidator,
impl<A, B> InputValueValidator for Or<A, B> where
A: InputValueValidator,
B: InputValueValidator,
impl<I, F> InputValueValidator for MapErr<I, F> where
I: InputValueValidator,
F: Fn(String) -> String + Send + Sync,