[−][src]Trait async_graphql::validators::InputValueValidator
Input value validator
You can create your own input value validator by implementing this trait.
use async_graphql::*; use async_graphql::validators::{Email, MAC, IntRange}; struct QueryRoot; #[Object] impl QueryRoot { // Input is email address #[field] async fn value1(&self, #[arg(validators(Email))] email: String) -> i32 { unimplemented!() } // Input is email or MAC address #[field] async fn value2(&self, #[arg(validators(or(Email, MAC(colon: false))))] email_or_mac: String) -> i32 { unimplemented!() } // Input is integer between 100 and 200 #[field] async fn value3(&self, #[arg(validators(IntRange(min = 100, max = 200)))] value: i32) -> i32 { unimplemented!() } }
Required methods
fn is_valid(&self, value: &Value) -> Option<String>
Check value is valid, returns the reason for the error if it fails, otherwise None.