Files
klz-cables.com/.pnpm-store/v10/files/89/e5fe49b8b0b0d4a7d88d09190f76775f1165089a692148485636741b242c91acca4b9bd6f8763e113d69edf17e86be7579f06e6b7b3a73916c505c48571a33
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

36 lines
1.5 KiB
Plaintext

import { GraphQLScalarType, Kind } from 'graphql';
import { createGraphQLError } from '../error.js';
const validate = (value, ast) => {
const EMAIL_ADDRESS_REGEX = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
if (typeof value !== 'string') {
throw createGraphQLError(`Value is not string: ${value}`, { nodes: ast });
}
if (!EMAIL_ADDRESS_REGEX.test(value)) {
throw createGraphQLError(`Value is not a valid email address: ${value}`, { nodes: ast });
}
return value;
};
const specifiedByURL = 'https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address';
export const GraphQLEmailAddressConfig = /*#__PURE__*/ {
name: 'EmailAddress',
description: 'A field whose value conforms to the standard internet email address format as specified in HTML Spec: https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address.',
serialize: validate,
parseValue: validate,
parseLiteral(ast) {
if (ast.kind !== Kind.STRING) {
throw createGraphQLError(`Can only validate strings as email addresses but got a: ${ast.kind}`, { nodes: ast });
}
return validate(ast.value, ast);
},
specifiedByURL,
specifiedByUrl: specifiedByURL,
extensions: {
codegenScalarType: 'string',
jsonSchema: {
type: 'string',
format: 'email',
},
},
};
export const GraphQLEmailAddress = /*#__PURE__*/ new GraphQLScalarType(GraphQLEmailAddressConfig);