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?