UNPKG

@terabits/grapi

Version:

Grapi Schema Generator For GraphQL Server

26 lines (25 loc) 796 B
"use strict"; exports.__esModule = true; exports.Email = void 0; var graphql_1 = require("graphql"); var validator_1 = require("validator"); var parseAndSerializeValue = function (value) { if ((0, validator_1.isEmail)(value)) { return value; } throw new Error("Wrong \"".concat(value, "\" email. Does not match the standard")); }; var parseLiteral = function (ast) { if ((0, validator_1.isEmail)(ast.value)) { return ast.value; } throw new Error("Wrong \"".concat(ast.value, "\" email. Does not match the standard")); }; var Email = new graphql_1.GraphQLScalarType({ name: 'Email', description: 'Email format', serialize: parseAndSerializeValue, parseValue: parseAndSerializeValue, parseLiteral: parseLiteral }); exports.Email = Email;