{"id":18132708,"url":"https://github.com/mvalitov/phone_number","last_synced_at":"2025-04-16T05:57:18.710Z","repository":{"id":45052867,"uuid":"113306338","full_name":"mvalitov/phone_number","owner":"mvalitov","description":"Phone number validating for Elixir","archived":false,"fork":false,"pushed_at":"2022-02-15T08:26:39.000Z","size":389,"stargazers_count":10,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T05:05:22.949Z","etag":null,"topics":["elixir","phonelib"],"latest_commit_sha":null,"homepage":"https://hex.pm/packages/phone_number","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mvalitov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-06T11:12:51.000Z","updated_at":"2023-05-08T05:15:15.000Z","dependencies_parsed_at":"2022-09-19T07:50:27.129Z","dependency_job_id":null,"html_url":"https://github.com/mvalitov/phone_number","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvalitov%2Fphone_number","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvalitov%2Fphone_number/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvalitov%2Fphone_number/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvalitov%2Fphone_number/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mvalitov","download_url":"https://codeload.github.com/mvalitov/phone_number/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249205710,"owners_count":21229976,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","phonelib"],"created_at":"2024-11-01T13:05:21.754Z","updated_at":"2025-04-16T05:57:18.688Z","avatar_url":"https://github.com/mvalitov.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PhoneNumber\n\nLibrary for validating international phone numbers. Based on Google's libphonenumber.\n\n## Installation\n\nAdd `phone_number` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:phone_number, \"~\u003e 0.2.4\"}\n  ]\nend\n```\n\nTo update to version `0.2.0`, you must delete the `telephone_number_data.dat` file.\n\nDocumentation [HexDocs](https://hexdocs.pm/phone_number)\n\n## Usage\n\nParse phone:\n\n```elixir\niex\u003e p = PhoneNumber.parse(\"381601234567\")\n%PhoneNumber.Phone{\n  country: %PhoneNumber.Country{\n    country_code: \"381\",\n    data: %{},\n    full_general_pattern: ~r/^(381)?(0)?(?\u003cnational_num\u003e[126-9]\\d{4,11}|3(?:[0-79]\\d{3,10}|8[2-9]\\d{2,9}))$/,\n    general_validation: ~r/[126-9]\\d{4,11}|3(?:[0-79]\\d{3,10}|8[2-9]\\d{2,9})/,\n    id: \"RS\",\n    main_country_for_code: false,\n    mobile_token: nil,\n    national_prefix: \"0\",\n    national_prefix_for_parsing: nil,\n    national_prefix_transform_rule: \"\",\n    validations: [~r/^((?:1(?:[02-9][2-9]|1[1-9])\\d|2(?:[0-24-7][2-9]\\d|[389](?:0[2-9]|[2-9]\\d))|3(?:[0-8][2-9]\\d|9(?:[2-9]\\d|0[2-9])))\\d{3,8})$/,\n     ~r/^(6(?:[0-689]|7\\d)\\d{6,7})$/, ~r/^(800\\d{3,9})$/,\n     ~r/^((?:90[0169]|78\\d)\\d{3,7})$/, ~r/^(7[06]\\d{4,10})$/]\n  },\n  original_number: \"381601234567\",\n  valid: true\n}\n\niex\u003e PhoneNumber.Phone.e164_number(p)\n{:ok, \"+38181601234567\"}\n\nex(2)\u003e PhoneNumber.parse(\"381601234567\", \"RS\")\n%PhoneNumber.Phone{\n  country: %PhoneNumber.Country{\n    country_code: \"381\",\n    data: %{},\n    full_general_pattern: ~r/^(381)?(0)?(?\u003cnational_num\u003e[126-9]\\d{4,11}|3(?:[0-79]\\d{3,10}|8[2-9]\\d{2,9}))$/,\n    general_validation: ~r/[126-9]\\d{4,11}|3(?:[0-79]\\d{3,10}|8[2-9]\\d{2,9})/,\n    id: \"RS\",\n    main_country_for_code: false,\n    mobile_token: nil,\n    national_prefix: \"0\",\n    national_prefix_for_parsing: nil,\n    national_prefix_transform_rule: \"\",\n    validations: [~r/^((?:1(?:[02-9][2-9]|1[1-9])\\d|2(?:[0-24-7][2-9]\\d|[389](?:0[2-9]|[2-9]\\d))|3(?:[0-8][2-9]\\d|9(?:[2-9]\\d|0[2-9])))\\d{3,8})$/,\n     ~r/^(6(?:[0-689]|7\\d)\\d{6,7})$/, ~r/^(800\\d{3,9})$/,\n     ~r/^((?:90[0169]|78\\d)\\d{3,7})$/, ~r/^(7[06]\\d{4,10})$/]\n  },\n  original_number: \"381601234567\",\n  valid: true\n}\n\niex(3)\u003e PhoneNumber.valid?(\"381601234567\", \"RS\")\n{:ok,\n %PhoneNumber.Phone{\n   country: %PhoneNumber.Country{\n     country_code: \"381\",\n     data: %{},\n     full_general_pattern: ~r/^(381)?(0)?(?\u003cnational_num\u003e[126-9]\\d{4,11}|3(?:[0-79]\\d{3,10}|8[2-9]\\d{2,9}))$/,\n     general_validation: ~r/[126-9]\\d{4,11}|3(?:[0-79]\\d{3,10}|8[2-9]\\d{2,9})/,\n     id: \"RS\",\n     main_country_for_code: false,\n     mobile_token: nil,\n     national_prefix: \"0\",\n     national_prefix_for_parsing: nil,\n     national_prefix_transform_rule: \"\",\n     validations: [~r/^((?:1(?:[02-9][2-9]|1[1-9])\\d|2(?:[0-24-7][2-9]\\d|[389](?:0[2-9]|[2-9]\\d))|3(?:[0-8][2-9]\\d|9(?:[2-9]\\d|0[2-9])))\\d{3,8})$/,\n      ~r/^(6(?:[0-689]|7\\d)\\d{6,7})$/, ~r/^(800\\d{3,9})$/,\n      ~r/^((?:90[0169]|78\\d)\\d{3,7})$/, ~r/^(7[06]\\d{4,10})$/]\n   },\n   original_number: \"381601234567\",\n   valid: true\n }}\niex(4)\u003e PhoneNumber.valid?(\"481601234567\", \"RS\")\n{:ok, nil}\n\niex(5)\u003e PhoneNumber.possible_countries(\"381601234567\")\n[\n  %PhoneNumber.Phone{\n    country: %PhoneNumber.Country{\n      country_code: \"49\",\n      data: %{},\n      full_general_pattern: ~r/^(49)?(0)?(?\u003cnational_num\u003e[1-35-9]\\d{3,14}|4(?:[0-8]\\d{3,12}|9(?:[0-37]\\d|4(?:[1-35-8]|4\\d?)|5\\d{1,2}|6[1-8]\\d?)\\d{2,8}))$/,\n      general_validation: ~r/[1-35-9]\\d{3,14}|4(?:[0-8]\\d{3,12}|9(?:[0-37]\\d|4(?:[1-35-8]|4\\d?)|5\\d{1,2}|6[1-8]\\d?)\\d{2,8})/,\n      id: \"DE\",\n      main_country_for_code: false,\n      mobile_token: nil,\n      national_prefix: \"0\",\n      national_prefix_for_parsing: nil,\n      national_prefix_transform_rule: \"\",\n      validations: [~r/^(2\\d{5,13}|3(?:0\\d{3,13}|2\\d{9}|[3-9]\\d{4,13})|4(?:0\\d{3,12}|[1-8]\\d{4,12}|9(?:[0-37]\\d|4(?:[1-35-8]|4\\d?)|5\\d{1,2}|6[1-8]\\d?)\\d{2,8})|5(?:0[2-8]|[1256]\\d|[38][0-8]|4\\d{0,2}|[79][0-7])\\d{3,11}|6(?:\\d{5,13}|9\\d{3,12})|7(?:0[2-8]|[1-9]\\d)\\d{3,10}|8(?:0[2-9]|[1-8]\\d|9\\d?)\\d{3,10}|9(?:0[6-9]\\d{3,10}|1\\d{4,12}|[2-9]\\d{4,11}))$/,\n       ~r/^(1(?:5[0-25-9]\\d{8}|6[023]\\d{7,8}|7\\d{8,9}))$/,\n       ~r/^(16(?:4\\d{1,10}|[89]\\d{1,11}))$/, ~r/^(800\\d{7,12})$/,\n       ~r/^(137[7-9]\\d{6}|900(?:[135]\\d{6}|9\\d{7}))$/,\n       ~r/^(1(?:3(?:7[1-6]\\d{6}|8\\d{4})|80\\d{5,11}))$/, ~r/^(700\\d{8})$/,\n       ~r/^(18(?:1\\d{5,11}|[2-9]\\d{8}))$/,\n       ~r/^(1(?:5(?:(?:2\\d55|7\\d99|9\\d33)\\d{7}|(?:[034568]00|113)\\d{8})|6(?:013|255|399)\\d{7,8}|7(?:[015]13|[234]55|[69]33|[78]99)\\d{7,8}))$/]\n    },\n    original_number: \"381601234567\",\n    valid: true\n  },\n  %PhoneNumber.Phone{\n    country: %PhoneNumber.Country{\n      country_code: \"381\",\n      data: %{},\n      full_general_pattern: ~r/^(381)?(0)?(?\u003cnational_num\u003e[126-9]\\d{4,11}|3(?:[0-79]\\d{3,10}|8[2-9]\\d{2,9}))$/,\n      general_validation: ~r/[126-9]\\d{4,11}|3(?:[0-79]\\d{3,10}|8[2-9]\\d{2,9})/,\n      id: \"RS\",\n      main_country_for_code: false,\n      mobile_token: nil,\n      national_prefix: \"0\",\n      national_prefix_for_parsing: nil,\n      national_prefix_transform_rule: \"\",\n      validations: [~r/^((?:1(?:[02-9][2-9]|1[1-9])\\d|2(?:[0-24-7][2-9]\\d|[389](?:0[2-9]|[2-9]\\d))|3(?:[0-8][2-9]\\d|9(?:[2-9]\\d|0[2-9])))\\d{3,8})$/,\n       ~r/^(6(?:[0-689]|7\\d)\\d{6,7})$/, ~r/^(800\\d{3,9})$/,\n       ~r/^((?:90[0169]|78\\d)\\d{3,7})$/, ~r/^(7[06]\\d{4,10})$/]\n    },\n    original_number: \"381601234567\",\n    valid: true\n  }\n]\n```\n\nOn startup, the library loads the file `data/telephone_number_data.dat`.\n\nIf the file is not found, then the file `data/telephone_number_data.xml` is processed, which contains patterns for parsing the phone. \n\nIf you updated `telephone_number_data.xls`, you must delete the `data/telephone_number_data.dat` file, or run the `mix phone_number.load_phone_data` task\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvalitov%2Fphone_number","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmvalitov%2Fphone_number","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvalitov%2Fphone_number/lists"}