Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!