Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

154
Visualizações
Regex for Invalid emails

I have to create some validation for emails using regex.

I wrote these parts from the validation:

  const regex = {
  whitespace: /^(?!\s+$)/g,
  emailMultipleSeparatedBySemicolon:/^(\s?[^\s,]+@[^\s,]+\.[^\s,]+\s?;)*(\s?[^\s,]+@[^\s,]+\.[^\s,]+)$/g,
};

and I'm using it this way in the code:

 sendTo: Yup.string()
        .max(255, this.props.t("createEmail.error.errorTooLong255"))
        .matches(
          regex.emailMultipleSeparatedBySemicolon,
          this.props.t("createEmail.error.emailMultipleSeparatedBySemicolon")
        )
        .matches(
          regex.whitespace,
          this.props.t("createEmail.error.errorNoWhitespace")
        )
        .required(this.props.t("createEmail.error.required")),

However when I add more than one recipient like this: hNw6B@90.com;test , I don't get the error for invalid email, although the second one test (after the semicolon) is not valid. If I add it this way: hNw6B@90.com; test (with space between the semicolon and test) - it is marked as invalid.

I will be very grateful if you can help me out!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda