Phone number validation contrainst

Hello everyone,
I am writing a constraint to validate local phone number's.
Maximum lenght (9 chars) and must start with (80,81,82,83,84,85,89,90,97,98,99). I've written the constraint manually and it works fine.

regex(.,'[1]{9}$') and starts-with(., 81) or regex(.,'[2]{9}$') and starts-with(., 82) or regex(.,'[3]{9}$') and starts-with(., 83) or regex(.,'[4]{9}$') and starts-with(., 80) or regex(.,'[5]{9}$') and starts-with(., 84) or regex(.,'[6]{9}$') and starts-with(., 85) or regex(.,'[7]{9}$') and starts-with(., 89) or regex(.,'[8]{9}$') and starts-with(., 90) or regex(.,'[9]{9}$') and starts-with(., 97) or regex(.,'[10]{9}$') and starts-with(., 98) or regex(.,'[11]{9}$') and starts-with(., 99)

I just have the feeling that it's not the right way. I would have liked to put the numbers in an array and call the array on validation.
If anyone has an idea to make the constraint better, I'd be very happy.
Thanks


  1. 0-9 ↩︎

  2. 0-9 ↩︎

  3. 0-9 ↩︎

  4. 0-9 ↩︎

  5. 0-9 ↩︎

  6. 0-9 ↩︎

  7. 0-9 ↩︎

  8. 0-9 ↩︎

  9. 0-9 ↩︎

  10. 0-9 ↩︎

  11. 0-9 ↩︎

Phone number constraints have been discussed in the forum before, e.g. Phone number constraint. You may also find hints in the documentation, see https://docs.getodk.org/form-regex/ (and https://support.kobotoolbox.org/restrict_responses.html#:~:text=KoBoToolbox%20supports%20regex%20to%20control,valid%20email%20id%20etc.)
And you may find more with the search function, e.g. https://forum.getodk.org/search?context=topic&context_id=54445&q=phone%20number%20constraint%20regex&skip_context=true.

Thanks a lot Wroos!
My issue is resolved with this regex.