Skip to content

Validate a list of elements #6

@ErnestoCamilo

Description

@ErnestoCamilo
const { validator, validate } = require('@wiicamp/graphql-validation'); // Import module

const resolver = {
  Mutation: {
    ValidateEmails: validator([
      validate('students', 'data') // <--- Validate input types
       .not().isEmail({ msg: 'Not is email ' }),
    
    ], (parent, args, context, info) => {
      if (context.validationErrors) {
        // Validate failed
        console.log(context.validationErrors); // Do anything with this errors
        
        return;
      }
    
      
    }),
  },
};
Input: { data: { students: ["email1", "email2@gmail.com"] } };

How I can validate each email and get the correct answer?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions