-
Notifications
You must be signed in to change notification settings - Fork 1
Validate a list of elements #6
Copy link
Copy link
Open
Description
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?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels