All files / app/customer getEmailValidationSchema.ts

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  10x   10x           10x 32x   32x              
import { LanguageService } from '@bigcommerce/checkout-sdk';
import { object, string, ObjectSchema } from 'yup';
 
import { EMAIL_REGEXP } from './validationPatterns';
 
export interface EmailValidationSchemaOptions {
    language: LanguageService;
}
 
export default function getEmailValidationSchema({
    language,
}: EmailValidationSchemaOptions): ObjectSchema<{ email: string }> {
    return object({
        email: string()
            .max(256)
            .matches(EMAIL_REGEXP, language.translate('customer.email_invalid_error'))
            .required(language.translate('customer.email_required_error')),
    });
}