Validation of phone numbers in Ukraine
The phone number must conform to the format +380 aa xxx xxxx;+380 aaa xx xxxx;+380 аааа хх ххх
, where:
+380
is the code of Ukraine,аа
/ааа
/аааа
is the code of the operator or area,ххх хххх
/хх хххх
/хх ххх
- number format for seven-, six- and five-digit numbers that can be used in the local network without using the network code.
Toll-free phones 0 800 ххх ххх
must be specified without a country code, the phone:UA
key is used to record them.
Use emergency:phone=*
tag for adding emergency numbers.
- 112 - general emergency number, one for all services
- 101 - firefighters
- 102 - police
- 103 - ambulance
- 104 - gas service
- 109 - information desk
Use contact:phone=*
tag for adding short service numbers. So far, the rules for checking the short number of PrivatBank (3700).
meta { title: "Ukrainian phone numbers"; version: "0.12_2022-05-27"; description: "Verify Ukrainian phone numbers formatting and validity. Rules for checking phone number formats in Ukraine. The phone must conform to the format `+380 aa xxx xxxx;+380 aaa xx xxxx;+380 аааа хх ххх`, where `+380` is the code of Ukraine, `аа` / `ааа` / `аааа` is the code of the operator or area, `ххх хххх` / `хх хххх` / `хх ххх` - number format for seven-, six- and five-digit numbers that can be used in the local network without using the network code. Toll-free phones `0 800 ххх ххх` must be specified without a country code, the `phone:UA` key is used to record them."; author: "code: andygol; icon: gontsa"; icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iOTAwIiBoZWlnaHQ9IjYwMCIgdmVyc2lvbj0iMS4xIiBpZD0ic3ZnMTgwMCIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZGVmcyBpZD0iZGVmczE4MDQiPjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyIgaWQ9InN0eWxlMjA3NyI+LmZpbDAsLmZpbDF7ZmlsbDojMWIxYzFmfS5maWwxe2ZpbGwtcnVsZTpub256ZXJvfTwvc3R5bGU+PC9kZWZzPjxnIGlkPSJnMjAxOCIgdHJhbnNmb3JtPSJzY2FsZSguNzUpIj48cGF0aCBmaWxsPSIjMDA1YmJiIiB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Njk2LTMuMDM4bDEwLjU3OS0xMC41NjUgNS4yLTUuMjA3YzYuNDYtNi40NiA2LjYzOS0xNi43NzguNDE5LTIzLjAwMUw0Mi43MTUgNC43NjljLTYuMjE2LTYuMjE2LTE2LjU0MS02LjAyNy0yMy4wMDEuNDMzbC04LjgxOCA4Ljg2OC4yNDMuMjRjLTIuOTU2IDMuNzcyLTUuNDI5IDguMTI0LTcuMjY1IDEyLjgxNi0xLjY5NiA0LjQ2Ni0yLjc1MiA4LjcyOS0zLjIzNSAxMi45OTgtNC4xMyAzNC4yNSAxMS41MiA2NS41NSA1My45OTQgMTA4LjAyOCA1OC43MTEgNTguNzA3IDEwNi4wMjcgNTQuMjczIDEwOC4wNjcgNTQuMDU1IDQuNDQ5LS41MyA4LjcwNy0xLjU5MyAxMy4wMzgtMy4yNzUgNC42NTItMS44MTggOS4wMDEtNC4yODQgMTIuNzY5LTcuMjMzbC4xOTMuMTY4IDguOTMzLTguNzQ3YzYuNDQ2LTYuNDU5IDYuNjMyLTE2Ljc3Ny40MTUtMjMuMDE1eiIgaWQ9InBhdGgyMjQwIi8+PC9nPjwvZz48L2c+PC9zdmc+"; link: "https://josm.openstreetmap.de/wiki/Rules/UkrainePhoneNumbers"; min-josm-version: "11424"; /* due to territory selectors */ baselanguage: "en"; } meta[lang=uk] { title: "Правила перевірки форматів телефонних номерів в Україні"; description: "Правила перевірки форматів номерів телефонів в Україні. Телефон має відповідати формату `+380 aa xxx xxxx;+380 aaa xx xxxx;+380 аааа хх ххх`, де `+380` - код України, `аа` / `ааа` / `аааа` - код оператора чи території, `ххх хххх` / `хх хххх` / `хх ххх` - формат номерів для семи-, шести- та п'ятизначних номерів, що можуть використовуватись в місцевій мережі без використання коду мережі. Телефони `0 800 ххх ххх` мають вказуватись без коду країни, для їх запису використовується ключ `phone:UA`"; } *[/^(contact:)?(phone|fax)(?!:UA)$/][/^(contact:)?(phone|fax)(?!:UA)$/ !~ /^((;?(?=(\+\b380 [3-9][0-9][0-9 ]{9}\b)|(0 800 \d{3} \d{3})|(3700))(?=.*(\b(3700)\b|\b(0 800 \d{3} \d{3})\b|(\+\b380 (?:\d{2} \d{3} \d{4}|\d{3} \d{2} \d{4}|\d{4} \d{2} \d{3})\b)))(\b(3700)\b|\b(0 800 \d{3} \d{3})\b|(\+\b380 (?:\d{2} \d{3} \d{4}|\d{3} \d{2} \d{4}|\d{4} \d{2} \d{3})\b)))*)$/][inside("UA")] { throwWarning: tr("{0}", "{0.tag}"); group: tr("Incorrect \"phone\" tag"); suggestAlternative: tr("format +380⎵44⎵123⎵4567;+380⎵352⎵12⎵3456;+380⎵5345⎵12⎵345"); assertMatch: "node phone=+380 44 366 7002"; assertNoMatch: "node phone=+38 044 366 7002"; } *["phone" =~ /^(;?(0 800 \d{3} \d{3}))*$/][inside("UA")], *["contact:phone" =~ /^(;?(0 800 \d{3} \d{3}))*$/][inside("UA")] { throwError: tr("{0}", ""); group: tr("A toll-free phone number is listed in the \"phone\" tag"); fixChangeKey: "{0.key}=>phone:UA"; assertMatch: "node phone=0 800 500 609"; assertMatch: "way phone=0 800 500 609"; assertNoMatch: "node phone:UA=0800 500 609"; assertNoMatch: "way phone:UA=0800 500 609"; } *[/^(contact:)?(phone|fax)(?!:UA)$/][/^(contact:)?(phone|fax)(?!:UA)$/ =~ /800(([ -]\d{3}){2}|([ -]\d{2}){3})/][inside("UA")] { throwWarning: tr("{0}", "{0.tag}"); group: tr("Toll-free number among other phones"); suggestAlternative: tr("ex. phone:UA=0⎵800⎵300⎵545"); } *["phone:UA"]["phone:UA" !~ /^(;?(0 800 \d{3} \d{3}))*$/][inside("UA")] { throwWarning: tr("{0}", "{0.tag}"); group: tr("Incorrect format of the toll-free number"); suggestAlternative: tr("ex. phone:UA=0⎵800⎵300⎵545"); } *["emergency:phone"]["emergency:phone" !~ /^(;?(?=(112|10[1-49]))(?=.*(112|10[1-49]))(112|10[1-49]))*$/][inside("UA")] { throwWarning: tr("({0}). \"emergency:phone=*\" value must be one of 112, 101, 102, 103, 104, 109", "{0.tag}"); } /*+380 3333 00 102 - fixed. Here, 102 is a part of the number, not an emergency phone by itself*/ *[/^(contact:)?(phone|fax)(?!:UA)$/][/^(contact:)?(phone|fax)(?!:UA)$/ =~ /;?(?=\b(112|10[1-49])\b)(?<! )(112|10[1-49])*/][inside("UA")] { throwWarning: tr("Emergency phone number is in the \"phone\" tag"); suggestAlternative: tr("\"emergency:phone=*\""); } *[/(phone|fax)/ =~ /\d; *$/][inside("UA")] { throwWarning: tr("{0}", ""); group: tr("Empty value after \";\" at the end of the phone/fax tag"); } /* privatbank short number - not tested yet */ *["phone" =~ /\b3700\b/][/^name(:\w\w)?$/ =~ /^(?i)(?u)(ПриватБанк)$/][inside("UA")] { throwError: tr("{0}", ""); group: tr("Privatbank short number is listed in the \"phone\" tag"); suggestAlternative: tr("contact:phone = 3700 for short number"); }
Rules_UkrainePhoneNumbers.validator.mapcss, Rules_UkrainePhoneNumbers.zip
Attachments (1)
-
Flag_of_Ukraine_phone_check.svg
(1.5 KB
) - added by 2 years ago.
Validator Icon, reuploaded icon of andygol but with: (NOZIP)
Download all attachments as: .zip