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

147
Visualizações
Email validation coding in node.is

This is the email validation coding.

I only know to do example 5, the email length must over 5 strings, otherwise, it will become error and remind people to re-write the email.

I don’t know how to write the example 2-4 based on the email requirements. Kindly please give me some advices. Thank you so much!

function validateEmail(email) {
    console.log(email)
  // email requirements as below:
  // email length >= 5 character
  // @ cannot be the first character
  // @ must before .
  // . cannot be the last character
  // example 
  // 1. a@a.com < return true
  // 2. @a.com < return false, throw TypeError: invalid email address
  // 3. a.b@com < return false, throw TypeError: invalid email address
  // 4. a@a.com. < return false, throw TypeError: invalid email address
  // 5. a@a.c < return false, throw TypeError: e-mail address too short
  // 6. a@.com < return ture
  // example 5, email length >= 5 character
  if(email.length<5) {
    throw new TypeError(`e-mail address too short`)
  }
  // example 4,  . cannot be the last character
  
  }
// example 1,6
    return true

    function newFunction() {
        return "'"
    }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can follow this REGAX for validate email. Please check

const emailToValidate = 'a@a.com';
const emailRegexp = /^[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])?)*$/;
console.log(emailRegexp.test(emailToValidate));

Thanks

about 4 years ago · Juan Pablo Isaza Relatório
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