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

146
Visualizações
How do I get a readlinesync input value to be accepted only if lawProcessNumber equals law, and if not, keep asking until that value equals law?

I'm writing a code that receives an input from a readline-sync question. If this value is different from the law structure, it must repeat the question until the value equals law.

For this code, I'm using javascript, puppeteer and readline-sync (libraries).

const lawProcessNumber = readlineSync.question(console.log(
    "Input a law process number like this example\n(0000000-00.0000.8.16.0000): "))
  const validNumber = /^(([0-9]{7}-[0-9]{2}.[0-9]{4}.8.16.[0-9]{4}))$/
  const law = validNumber.test(lawProcessNumber)
  if (!law) {
    return false
  }

For now, my code just receives the value and continues if everything is ok. If the value is not right, it stops.

I will use this input value in a future puppeteer code.

How do I get a readlinesync input value to be accepted only if lawProcessNumber equals law, and if not, keep asking until that value equals law?

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