Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way to validate the elements of Vec? #579

Closed
yoshi9930 opened this issue Jul 20, 2021 · 4 comments
Closed

Is there any way to validate the elements of Vec? #579

yoshi9930 opened this issue Jul 20, 2021 · 4 comments
Labels
question Further information is requested

Comments

@yoshi9930
Copy link

For example, if you validate the following input, the value will be validated.
Is there any way to validate the values element?

use async_graphql::validators::{Email, MAC};
use async_graphql::*;

pub struct Query;

#[Object]
impl Query {
    async fn input(
        &self,
        #[graphql(validator(or(Email, MAC(colon = "false"))))] value: String,
        #[graphql(validator(or(Email, MAC(colon = "false"))))] values: Vec<String>,
    ) -> bool {
        true
    }
}
@yoshi9930 yoshi9930 added the question Further information is requested label Jul 20, 2021
@sunli829
Copy link
Collaborator

Let me think about it.

@sunli829
Copy link
Collaborator

I added a list operator, here is an example:

pub async fn test_input_validator_list() {

@yoshi9930
Copy link
Author

Thanks for the feedback.

@yoshi9930
Copy link
Author

It's working as expected.

thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants