├── .credo.exs ├── .formatter.exs ├── .gitignore ├── .sourcelevel.yml ├── .travis.yml ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── bench └── phone_bench.exs ├── coveralls.json ├── lib ├── helpers │ ├── area.ex │ ├── country.ex │ └── parser.ex ├── phone.ex └── phone │ ├── ad.ex │ ├── ae.ex │ ├── af.ex │ ├── al.ex │ ├── am.ex │ ├── ao.ex │ ├── ar.ex │ ├── at.ex │ ├── au.ex │ ├── aw.ex │ ├── az.ex │ ├── ba.ex │ ├── bd.ex │ ├── be.ex │ ├── bg.ex │ ├── bh.ex │ ├── bi.ex │ ├── bj.ex │ ├── bn.ex │ ├── bo.ex │ ├── br.ex │ ├── br │ ├── ac.ex │ ├── al.ex │ ├── am.ex │ ├── ap.ex │ ├── ba.ex │ ├── ce.ex │ ├── df.ex │ ├── es.ex │ ├── go.ex │ ├── ma.ex │ ├── mg.ex │ ├── ms.ex │ ├── mt.ex │ ├── pa.ex │ ├── pb.ex │ ├── pe.ex │ ├── pi.ex │ ├── pr.ex │ ├── rj.ex │ ├── rn.ex │ ├── ro.ex │ ├── rr.ex │ ├── rs.ex │ ├── sc.ex │ ├── se.ex │ ├── sp.ex │ ├── to.ex │ └── toll_free.ex │ ├── bt.ex │ ├── bw.ex │ ├── by.ex │ ├── bz.ex │ ├── cd.ex │ ├── cf.ex │ ├── cg.ex │ ├── ch.ex │ ├── ci.ex │ ├── ck.ex │ ├── cl.ex │ ├── cm.ex │ ├── cn.ex │ ├── co.ex │ ├── countries.ex │ ├── cr.ex │ ├── cu.ex │ ├── cv.ex │ ├── cw.ex │ ├── cy.ex │ ├── cz.ex │ ├── de.ex │ ├── dj.ex │ ├── dk.ex │ ├── dz.ex │ ├── ec.ex │ ├── ee.ex │ ├── eg.ex │ ├── er.ex │ ├── es.ex │ ├── es │ ├── a.ex │ ├── ab.ex │ ├── al.ex │ ├── av.ex │ ├── b.ex │ ├── ba.ex │ ├── bi.ex │ ├── bu.ex │ ├── c.ex │ ├── ca.ex │ ├── cc.ex │ ├── co.ex │ ├── cr.ex │ ├── cs.ex │ ├── cu.ex │ ├── gc.ex │ ├── gi.ex │ ├── gr.ex │ ├── gu.ex │ ├── h.ex │ ├── hu.ex │ ├── intelligent_numbers.ex │ ├── j.ex │ ├── l.ex │ ├── le.ex │ ├── lo.ex │ ├── lu.ex │ ├── m.ex │ ├── ma.ex │ ├── mobile.ex │ ├── mu.ex │ ├── na.ex │ ├── o.ex │ ├── or.ex │ ├── p.ex │ ├── pm.ex │ ├── po.ex │ ├── s.ex │ ├── sa.ex │ ├── se.ex │ ├── sg.ex │ ├── so.ex │ ├── ss.ex │ ├── t.ex │ ├── te.ex │ ├── tf.ex │ ├── to.ex │ ├── v.ex │ ├── va.ex │ ├── vi.ex │ ├── z.ex │ └── za.ex │ ├── et.ex │ ├── fi.ex │ ├── fj.ex │ ├── fm.ex │ ├── fo.ex │ ├── fr.ex │ ├── ga.ex │ ├── gb.ex │ ├── ge.ex │ ├── gf.ex │ ├── gh.ex │ ├── gi.ex │ ├── gl.ex │ ├── gm.ex │ ├── gn.ex │ ├── gp.ex │ ├── gq.ex │ ├── gr.ex │ ├── gt.ex │ ├── gw.ex │ ├── gy.ex │ ├── hk.ex │ ├── hn.ex │ ├── hr.ex │ ├── ht.ex │ ├── hu.ex │ ├── id.ex │ ├── ie.ex │ ├── il.ex │ ├── in.ex │ ├── io.ex │ ├── iq.ex │ ├── ir.ex │ ├── is.ex │ ├── it.ex │ ├── jo.ex │ ├── jp.ex │ ├── ke.ex │ ├── kg.ex │ ├── kh.ex │ ├── ki.ex │ ├── km.ex │ ├── kp.ex │ ├── kr.ex │ ├── kw.ex │ ├── kz.ex │ ├── la.ex │ ├── lb.ex │ ├── li.ex │ ├── lk.ex │ ├── lr.ex │ ├── ls.ex │ ├── lt.ex │ ├── lu.ex │ ├── lv.ex │ ├── ly.ex │ ├── ma.ex │ ├── mc.ex │ ├── md.ex │ ├── me.ex │ ├── mg.ex │ ├── mh.ex │ ├── mk.ex │ ├── ml.ex │ ├── mm.ex │ ├── mn.ex │ ├── mo.ex │ ├── mq.ex │ ├── mr.ex │ ├── mt.ex │ ├── mu.ex │ ├── mv.ex │ ├── mw.ex │ ├── mx.ex │ ├── my.ex │ ├── mz.ex │ ├── na.ex │ ├── nanp.ex │ ├── nanp │ ├── ag.ex │ ├── ai.ex │ ├── as.ex │ ├── bb.ex │ ├── bm.ex │ ├── bs.ex │ ├── ca.ex │ ├── ca │ │ ├── ab.ex │ │ ├── bc.ex │ │ ├── mb.ex │ │ ├── nb.ex │ │ ├── nl.ex │ │ ├── ns_and_pe.ex │ │ ├── on.ex │ │ ├── qc.ex │ │ ├── sk.ex │ │ └── territory.ex │ ├── dm.ex │ ├── do.ex │ ├── gd.ex │ ├── gu.ex │ ├── jm.ex │ ├── kn.ex │ ├── ky.ex │ ├── lc.ex │ ├── mp.ex │ ├── ms.ex │ ├── pr.ex │ ├── sx.ex │ ├── tc.ex │ ├── toll_free.ex │ ├── tt.ex │ ├── us.ex │ ├── us │ │ ├── ak.ex │ │ ├── al.ex │ │ ├── ar.ex │ │ ├── az.ex │ │ ├── ca.ex │ │ ├── co.ex │ │ ├── ct.ex │ │ ├── dc.ex │ │ ├── de.ex │ │ ├── fl.ex │ │ ├── ga.ex │ │ ├── hi.ex │ │ ├── ia.ex │ │ ├── id.ex │ │ ├── il.ex │ │ ├── in.ex │ │ ├── ks.ex │ │ ├── ky.ex │ │ ├── la.ex │ │ ├── ma.ex │ │ ├── md.ex │ │ ├── me.ex │ │ ├── mi.ex │ │ ├── mn.ex │ │ ├── mo.ex │ │ ├── ms.ex │ │ ├── mt.ex │ │ ├── nc.ex │ │ ├── nd.ex │ │ ├── ne.ex │ │ ├── nh.ex │ │ ├── nj.ex │ │ ├── nm.ex │ │ ├── nv.ex │ │ ├── ny.ex │ │ ├── oh.ex │ │ ├── ok.ex │ │ ├── or.ex │ │ ├── pa.ex │ │ ├── ri.ex │ │ ├── sc.ex │ │ ├── sd.ex │ │ ├── tn.ex │ │ ├── tx.ex │ │ ├── ut.ex │ │ ├── va.ex │ │ ├── vt.ex │ │ ├── wa.ex │ │ ├── wi.ex │ │ ├── wv.ex │ │ └── wy.ex │ ├── vc.ex │ ├── vg.ex │ └── vi.ex │ ├── nc.ex │ ├── ne.ex │ ├── nf.ex │ ├── ng.ex │ ├── ni.ex │ ├── nl.ex │ ├── no.ex │ ├── np.ex │ ├── nr.ex │ ├── nu.ex │ ├── nz.ex │ ├── om.ex │ ├── pa.ex │ ├── pe.ex │ ├── pf.ex │ ├── pg.ex │ ├── ph.ex │ ├── pk.ex │ ├── pl.ex │ ├── pm.ex │ ├── ps.ex │ ├── pt.ex │ ├── pw.ex │ ├── py.ex │ ├── qa.ex │ ├── re.ex │ ├── ro.ex │ ├── rs.ex │ ├── ru.ex │ ├── rw.ex │ ├── sa.ex │ ├── sb.ex │ ├── sc.ex │ ├── sd.ex │ ├── se.ex │ ├── sg.ex │ ├── sh.ex │ ├── si.ex │ ├── sk.ex │ ├── sl.ex │ ├── sm.ex │ ├── sn.ex │ ├── so.ex │ ├── sr.ex │ ├── ss.ex │ ├── st.ex │ ├── sv.ex │ ├── sy.ex │ ├── sz.ex │ ├── td.ex │ ├── tg.ex │ ├── th.ex │ ├── tj.ex │ ├── tk.ex │ ├── tl.ex │ ├── tm.ex │ ├── tn.ex │ ├── to.ex │ ├── tr.ex │ ├── tv.ex │ ├── tw.ex │ ├── tz.ex │ ├── ua.ex │ ├── ug.ex │ ├── uy.ex │ ├── uz.ex │ ├── ve.ex │ ├── vn.ex │ ├── vu.ex │ ├── wf.ex │ ├── ws.ex │ ├── ye.ex │ ├── za.ex │ ├── zm.ex │ └── zw.ex ├── mix.exs └── test ├── phone ├── a_countries │ ├── ad_test.exs │ ├── ae_test.exs │ ├── af_test.exs │ ├── al_test.exs │ ├── am_test.exs │ ├── ao_test.exs │ ├── ar_test.exs │ ├── at_test.exs │ ├── au_test.exs │ ├── aw_test.exs │ └── az_test.exs ├── b_countries │ ├── ba_test.exs │ ├── bd_test.exs │ ├── be_test.exs │ ├── bg_test.exs │ ├── bh_test.exs │ ├── bi_test.exs │ ├── bj_test.exs │ ├── bn_test.exs │ ├── bo_test.exs │ ├── br_test.exs │ ├── bt_test.exs │ ├── bw_test.exs │ ├── by_test.exs │ └── bz_test.exs ├── c_countries │ └── ca_test.exs ├── countries_test.exs ├── e_countries │ └── es_test.exs ├── nanp_test.exs └── u_countries │ └── us_test.exs ├── phone_test.exs └── test_helper.exs /.formatter.exs: -------------------------------------------------------------------------------- 1 | # Used by "mix format" 2 | [ 3 | inputs: [ 4 | "{mix,.formatter}.exs", 5 | "{config,lib,test,bench}/**/*.{ex,exs}" 6 | ], 7 | locals_without_parens: [ 8 | # Formatter tests 9 | assert_format: 2, 10 | assert_format: 3, 11 | assert_same: 1, 12 | assert_same: 2, 13 | 14 | # Errors tests 15 | assert_eval_raise: 3, 16 | 17 | # Mix tests 18 | in_fixture: 2, 19 | in_tmp: 2 20 | ] 21 | ] 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # The directory Mix will write compiled artifacts to. 2 | /_build/ 3 | 4 | # If you run "mix test --cover", coverage assets end up here. 5 | /cover/ 6 | 7 | # The directory Mix downloads your dependencies sources to. 8 | /deps/ 9 | 10 | # Where third-party dependencies like ExDoc output generated docs. 11 | /doc/ 12 | 13 | # Ignore .fetch files in case you like to edit your project deps locally. 14 | /.fetch 15 | 16 | # If the VM crashes, it generates a dump, let's ignore it too. 17 | erl_crash.dump 18 | 19 | # Also ignore archive artifacts (built via "mix archive.build"). 20 | *.ez 21 | 22 | # Ignore package tarball (built via "mix hex.build"). 23 | phone-*.tar 24 | 25 | # Temporary files for e.g. tests. 26 | /tmp/ 27 | 28 | # Misc. 29 | /bench/snapshots/ 30 | .idea/ 31 | mix.lock 32 | *.iml 33 | -------------------------------------------------------------------------------- /.sourcelevel.yml: -------------------------------------------------------------------------------- 1 | styleguide: sourcelevel/linters 2 | engines: 3 | credo: 4 | enabled: true 5 | fixme: 6 | enabled: true 7 | remark-lint: 8 | enabled: false 9 | pull_requests: 10 | comments: false 11 | exclude_paths: 12 | - test 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: elixir 2 | 3 | elixir: 4 | - 1.7.4 5 | - 1.8.1 6 | 7 | otp_release: 8 | - 20.3.8 9 | - 21.2.6 10 | 11 | script: 12 | - MIX_ENV=test mix coveralls.travis --force 13 | 14 | after_script: 15 | - MIX_ENV=docs mix deps.get 16 | - MIX_ENV=docs mix inch.report 17 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at [INSERT EMAIL ADDRESS]. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at [http://contributor-covenant.org/version/1/4][version] 72 | 73 | [homepage]: http://contributor-covenant.org 74 | [version]: http://contributor-covenant.org/version/1/4/ 75 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | There are a couple of ways you can help this project grow, like: 2 | * Create an issue if you find any inconsistency with our parsing. If possible give us official information about the numbering plan of your country. 3 | * Create a PR adding area code info for a country that is missing. 4 | 5 | ### Helpers Modules 6 | 7 | #### Area Modules 8 | The helper for area module prepare everything for the expected behavior of this kind of modules, so you just need to write some static functions that will be overwritten and helps to identify information of what that module describes. The expected functions are: `regex/0`, `area_name/0`, `area_type/0`and `area_abbreviation/0`. There is the `matcher/1` macro, that will create the functions that makes heavy use of pattern matching, the argument is a list of values that will be pattern matched on calling functions, they're the combination of the country code and all the possible area code. 9 | ```elixir 10 | defmodule Phone.NANP.CA.AB do 11 | use Helper.Area 12 | 13 | def regex, do: ~r/^(1)(403|780|587|825)([2-9].{6})$/ 14 | def area_name, do: "Alberta" 15 | def area_type, do: "province" 16 | def area_abbreviation, do: "AB" 17 | 18 | matcher ["1403", "1780", "1587", "1825"] 19 | end 20 | ``` 21 | 22 | ### Country Modules 23 | Country modules works similar to area modules but there are two types of country modules. The first have the static functions to be overwritten, `regex/0`, `country/0`, `a2/0`, `a3/0`, and the macro `matcher/2`, the first parameter specifies that you must use `regex/0` to identify the number, the second works just as the list of pattern matchings you want to build to this module. 24 | ```elixir 25 | defmodule Phone.AE do 26 | use Helper.Country 27 | 28 | def regex, do: ~r/^(971)(.)(.{7})/ 29 | def country, do: "United Arab Emirates" 30 | def a2, do: "AE" 31 | def a3, do: "ARE" 32 | 33 | matcher :regex, ["971"] 34 | end 35 | ``` 36 | 37 | The second just need to overwrite the functions, `country/0`, `a2/0` and `a3/0`. The macro `matcher/2` now specifies that you must use the list of modules in the second parameter to identify the number. 38 | ```elixir 39 | defmodule Phone.NANP.CA do 40 | use Helper.Country 41 | 42 | def country, do: "Canada" 43 | def a2, do: "CA" 44 | def a3, do: "CAN" 45 | 46 | matcher :modules, [Phone.NANP.CA.AB, Phone.NANP.CA.BC, Phone.NANP.CA.MB, 47 | Phone.NANP.CA.NB, Phone.NANP.CA.NL, Phone.NANP.CA.NSAndPE, 48 | Phone.NANP.CA.ON, Phone.NANP.CA.QC, Phone.NANP.CA.SK, 49 | Phone.NANP.CA.Territory] 50 | end 51 | ``` 52 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Flávio Moreira Vieira 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /bench/phone_bench.exs: -------------------------------------------------------------------------------- 1 | defmodule PhoneBench do 2 | use Benchfella 3 | 4 | @nanp_phone_number "12536301234" 5 | @andorra_phone_number "376123456" 6 | @zimbabwe_phone_number "2634333224" 7 | 8 | bench "Phone.parse/1 with an NANP phone number" do 9 | {:ok, _result} = Phone.parse(@nanp_phone_number) 10 | end 11 | 12 | bench "Phone.parse/1 with an NANP phone number error" do 13 | {:error, _result} = Phone.parse("1253630123") 14 | end 15 | 16 | bench "Phone.parse/1 with an Andorra phone number" do 17 | {:ok, _result} = Phone.parse(@andorra_phone_number) 18 | end 19 | 20 | bench "Phone.parse/1 with an Andorra phone number error" do 21 | {:error, _result} = Phone.parse("37612345") 22 | end 23 | 24 | bench "Phone.parse/1 with a Zimbabwe phone number" do 25 | {:ok, _result} = Phone.parse(@zimbabwe_phone_number) 26 | end 27 | 28 | bench "Phone.parse/1 with a Zimbabwe phone number error" do 29 | {:error, _result} = Phone.parse("263") 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /coveralls.json: -------------------------------------------------------------------------------- 1 | { 2 | "skip_files": [ 3 | "lib/helpers/" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /lib/helpers/area.ex: -------------------------------------------------------------------------------- 1 | defmodule Helper.Area do 2 | @moduledoc false 3 | defmacro __using__(_) do 4 | quote do 5 | import Helper.Area 6 | 7 | def regex, do: "" 8 | def area_name, do: "" 9 | def area_type, do: "" 10 | def area_abbreviation, do: "" 11 | 12 | defoverridable regex: 0, area_name: 0, area_type: 0, area_abbreviation: 0 13 | 14 | def builder(number) do 15 | [_ | country] = 16 | __MODULE__ 17 | |> Module.split() 18 | |> Enum.reverse() 19 | 20 | country = 21 | country 22 | |> Enum.reverse() 23 | |> Module.concat() 24 | 25 | [[_, code, area, number]] = Regex.scan(regex(), number) 26 | 27 | %{ 28 | country: country.country(), 29 | a2: country.a2(), 30 | a3: country.a3(), 31 | international_code: code, 32 | number: number, 33 | area_code: area, 34 | area_name: area_name(), 35 | area_type: area_type(), 36 | area_abbreviation: area_abbreviation() 37 | } 38 | end 39 | end 40 | end 41 | 42 | defp generate_codes(codes) do 43 | [ 44 | quote do 45 | def codes, do: unquote(codes) 46 | end 47 | ] 48 | end 49 | 50 | defp generate_errors do 51 | [ 52 | quote do 53 | def build(_number), do: {:error, "Not a valid phone number."} 54 | 55 | def build!(_number), do: raise(ArgumentError, message: "Not a valid phone number.") 56 | 57 | def match?(_number), do: false 58 | end 59 | ] 60 | end 61 | 62 | defp generate_matcher(code) do 63 | quote do 64 | def match?(unquote(code) <> _ = number) do 65 | Regex.match?(regex(), number) 66 | end 67 | 68 | def build(unquote(code) <> _ = number) do 69 | if match?(number) do 70 | {:ok, builder(number)} 71 | else 72 | {:error, "Not a valid phone number."} 73 | end 74 | end 75 | 76 | def build!(unquote(code) <> _ = number) do 77 | if match?(number) do 78 | builder(number) 79 | else 80 | raise ArgumentError, message: "Not a valid phone number." 81 | end 82 | end 83 | end 84 | end 85 | 86 | defmacro matcher(codes) do 87 | generate_codes(codes) ++ 88 | Enum.map(codes, fn code -> 89 | generate_matcher(code) 90 | end) ++ generate_errors() 91 | end 92 | end 93 | -------------------------------------------------------------------------------- /lib/helpers/country.ex: -------------------------------------------------------------------------------- 1 | defmodule Helper.Country do 2 | @moduledoc false 3 | defmacro __using__(_) do 4 | quote do 5 | import Helper.Country 6 | 7 | def regex, do: "" 8 | def country, do: "" 9 | def a2, do: "" 10 | def a3, do: "" 11 | 12 | defoverridable regex: 0, country: 0, a2: 0, a3: 0 13 | 14 | def builder(number) do 15 | [[_, code, area, number]] = Regex.scan(regex(), number) 16 | 17 | %{ 18 | country: country(), 19 | a2: a2(), 20 | a3: a3(), 21 | international_code: code, 22 | area_code: area, 23 | number: number 24 | } 25 | end 26 | end 27 | end 28 | 29 | defp generate_codes(codes) do 30 | [ 31 | quote do 32 | def codes, do: unquote(codes) 33 | end 34 | ] 35 | end 36 | 37 | defp generate_errors do 38 | [ 39 | quote do 40 | def match?(_number), do: false 41 | 42 | def build!(_number), do: raise(ArgumentError, "Not a valid phone number.") 43 | 44 | def build(_number), do: {:error, "Not a valid phone number."} 45 | end 46 | ] 47 | end 48 | 49 | def generate_matcher(:regex, code) do 50 | quote do 51 | def match?(unquote(code) <> _ = number) do 52 | Regex.match?(regex(), number) 53 | end 54 | 55 | def build(unquote(code) <> _ = number) do 56 | if match?(number) do 57 | {:ok, builder(number)} 58 | else 59 | {:error, "Not a valid phone number."} 60 | end 61 | end 62 | 63 | def build!(unquote(code) <> _ = number) do 64 | if match?(number) do 65 | builder(number) 66 | else 67 | raise ArgumentError, "Not a valid phone number." 68 | end 69 | end 70 | end 71 | end 72 | 73 | def generate_matcher(:modules, module, code) do 74 | quote do 75 | def match?(unquote(code) <> _ = number) do 76 | unquote(module).match?(number) 77 | end 78 | 79 | def build(unquote(code) <> _ = number) do 80 | unquote(module).build(number) 81 | end 82 | 83 | def build!(unquote(code) <> _ = number) do 84 | unquote(module).build!(number) 85 | end 86 | end 87 | end 88 | 89 | defmacro matcher(:regex, codes) do 90 | generate_codes(codes) ++ 91 | Enum.map(codes, fn code -> 92 | generate_matcher(:regex, code) 93 | end) ++ generate_errors() 94 | end 95 | 96 | defmacro matcher(:modules, modules) do 97 | modules = Enum.map(modules, &Macro.expand(&1, __CALLER__)) 98 | 99 | (modules 100 | |> Enum.reduce([], fn m, acc -> acc ++ m.codes() end) 101 | |> generate_codes) ++ 102 | Enum.map(modules, fn module -> 103 | Enum.map(module.codes(), fn code -> 104 | generate_matcher(:modules, module, code) 105 | end) 106 | end) ++ generate_errors() 107 | end 108 | 109 | defmacro matcher(_, _), 110 | do: raise(ArgumentError, "You can only match against :regex or :modules") 111 | end 112 | -------------------------------------------------------------------------------- /lib/phone/ad.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.AD do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(376)()(.{6})/ 7 | def country, do: "Andorra" 8 | def a2, do: "AD" 9 | def a3, do: "AND" 10 | 11 | matcher(:regex, ["376"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ae.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.AE do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(971)(.{1,2})(.{7})/ 7 | def country, do: "United Arab Emirates" 8 | def a2, do: "AE" 9 | def a3, do: "ARE" 10 | 11 | matcher(:regex, ["971"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/af.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.AF do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(93)(..)(.{7})/ 7 | def country, do: "Afghanistan" 8 | def a2, do: "AF" 9 | def a3, do: "AFG" 10 | 11 | matcher(:regex, ["93"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/al.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.AL do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(355)()(.{7})/ 7 | def country, do: "Albania" 8 | def a2, do: "AL" 9 | def a3, do: "ALB" 10 | 11 | matcher(:regex, ["355"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/am.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.AM do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(374)()(.{8})/ 7 | def country, do: "Armenia" 8 | def a2, do: "AM" 9 | def a3, do: "ARM" 10 | 11 | matcher(:regex, ["374"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ao.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.AO do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(244)()(.{9})/ 7 | def country, do: "Angola" 8 | def a2, do: "AO" 9 | def a3, do: "AGO" 10 | 11 | matcher(:regex, ["244"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ar.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.AR do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(54)()(.{10})/ 7 | def country, do: "Argentina" 8 | def a2, do: "AR" 9 | def a3, do: "ARG" 10 | 11 | matcher(:regex, ["54"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/at.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.AT do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(43)()(.+)/ 7 | def country, do: "Austria" 8 | def a2, do: "AT" 9 | def a3, do: "AUT" 10 | 11 | matcher(:regex, ["43"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/au.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.AU do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(61)([1-478])(.{8,9})/ 7 | def country, do: "Australia" 8 | def a2, do: "AU" 9 | def a3, do: "AUS" 10 | 11 | matcher(:regex, ["611", "612", "613", "614", "617", "618"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/aw.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.AW do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(297)()(.{7})/ 7 | def country, do: "Aruba" 8 | def a2, do: "AW" 9 | def a3, do: "ABW" 10 | 11 | matcher(:regex, ["297"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/az.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.AZ do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(994)()(.{9})/ 7 | def country, do: "Azerbeijan" 8 | def a2, do: "AZ" 9 | def a3, do: "AZE" 10 | 11 | matcher(:regex, ["994"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ba.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BA do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(387)(..)(.{5,6})/ 7 | def country, do: "Bosnia and Herzegovina" 8 | def a2, do: "BA" 9 | def a3, do: "BIH" 10 | 11 | matcher(:regex, ["387"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/bd.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BD do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(880)()(.{10})/ 7 | def country, do: "Bangladesh" 8 | def a2, do: "BD" 9 | def a3, do: "BGD" 10 | 11 | matcher(:regex, ["880"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/be.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BE do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(32)()(.{8,9})/ 7 | def country, do: "Belgium" 8 | def a2, do: "BE" 9 | def a3, do: "BEL" 10 | 11 | matcher(:regex, ["32"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/bg.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BG do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(359)()(.{8,9})/ 7 | def country, do: "Bulgaria" 8 | def a2, do: "BG" 9 | def a3, do: "BGR" 10 | 11 | matcher(:regex, ["359"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/bh.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BH do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(973)()(.{8})/ 7 | def country, do: "Bahrain" 8 | def a2, do: "BH" 9 | def a3, do: "BHR" 10 | 11 | matcher(:regex, ["973"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/bi.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BI do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(257)()(.{8})/ 7 | def country, do: "Burundi" 8 | def a2, do: "BI" 9 | def a3, do: "BDI" 10 | 11 | matcher(:regex, ["257"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/bj.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BJ do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(229)()(.{8})/ 7 | def country, do: "Benin" 8 | def a2, do: "BJ" 9 | def a3, do: "BEN" 10 | 11 | matcher(:regex, ["229"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/bn.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BN do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(673)()(.{7})/ 7 | def country, do: "Brunei" 8 | def a2, do: "BN" 9 | def a3, do: "BRN" 10 | 11 | matcher(:regex, ["673"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/bo.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BO do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(591)()(.{8})/ 7 | def country, do: "Bolivia" 8 | def a2, do: "BO" 9 | def a3, do: "BOL" 10 | 11 | matcher(:regex, ["591"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def country, do: "Brazil" 7 | def a2, do: "BR" 8 | def a3, do: "BRA" 9 | 10 | matcher(:modules, [ 11 | Phone.BR.AC, 12 | Phone.BR.AL, 13 | Phone.BR.AM, 14 | Phone.BR.AP, 15 | Phone.BR.BA, 16 | Phone.BR.CE, 17 | Phone.BR.DF, 18 | Phone.BR.ES, 19 | Phone.BR.GO, 20 | Phone.BR.MA, 21 | Phone.BR.MT, 22 | Phone.BR.MS, 23 | Phone.BR.MG, 24 | Phone.BR.PA, 25 | Phone.BR.PB, 26 | Phone.BR.PE, 27 | Phone.BR.PI, 28 | Phone.BR.PR, 29 | Phone.BR.RJ, 30 | Phone.BR.RN, 31 | Phone.BR.RO, 32 | Phone.BR.RR, 33 | Phone.BR.RS, 34 | Phone.BR.SC, 35 | Phone.BR.SE, 36 | Phone.BR.SP, 37 | Phone.BR.TO 38 | ]) 39 | end 40 | -------------------------------------------------------------------------------- /lib/phone/br/ac.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.AC do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(68)([2-5|89].{7}|9[89].{7})$/ 7 | def area_name, do: "Acre" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "AC" 10 | 11 | matcher(["5568"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/al.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.AL do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(82)([2-5|89].{7}|9[89].{7})$/ 7 | def area_name, do: "Alagoas" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "AL" 10 | 11 | matcher(["5582"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/am.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.AM do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(9[27])([2-5|89].{7}|9[89].{7})$/ 7 | def area_name, do: "Amazonas" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "AM" 10 | 11 | matcher(["5592", "5597"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/ap.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.AP do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(96)([2-5|89].{7}|9[89].{7})$/ 7 | def area_name, do: "Amapá" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "AP" 10 | 11 | matcher(["5596"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/ba.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.BA do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(7[1|3-5|7])([2-5|89].{7}|9[89].{7}|78.{6})$/ 7 | def area_name, do: "Bahia" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "BA" 10 | 11 | matcher(["5571", "5573", "5574", "5575", "5577"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/ce.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.CE do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(8[58])([2-5|89].{7}|9[89].{7}|78.{6})$/ 7 | def area_name, do: "Ceará" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "CE" 10 | 11 | matcher(["5585", "5588"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/df.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.DF do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(61)([2-5|89].{7}|9[89].{7}|78.{6})$/ 7 | def area_name, do: "Distrito Federal" 8 | def area_type, do: "district" 9 | def area_abbreviation, do: "DF" 10 | 11 | matcher(["5561"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/es.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.ES do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(2[78])([2-5|89].{7}|9[89].{7}|78.{6})$/ 7 | def area_name, do: "Espírito Santo" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "ES" 10 | 11 | matcher(["5527", "5528"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/go.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.GO do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(6[24])([2-5|89].{7}|9[89].{7}|78.{6})$/ 7 | def area_name, do: "Goiás" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "GO" 10 | 11 | matcher(["5562", "5564"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/ma.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.MA do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(9[98])([2-5|89].{7}|9[89].{7})$/ 7 | def area_name, do: "Maranhão" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "MA" 10 | 11 | matcher(["5598", "5599"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/mg.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.MG do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(3[1-5|78])([2-5|89].{7}|9[89].{7}|7[78].{6})$/ 7 | def area_name, do: "Minas Gerais" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "MG" 10 | 11 | matcher(["5531", "5532", "5533", "5534", "5535", "5537", "5538"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/ms.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.MS do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(67)([2-5|89].{7}|9[89].{7})$/ 7 | def area_name, do: "Mato Grosso do Sul" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "MS" 10 | 11 | matcher(["5567"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/mt.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.MT do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(6[56])([2-5|89].{7}|9[89].{7}|78.{6})$/ 7 | def area_name, do: "Mato Grosso" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "MT" 10 | 11 | matcher(["5565", "5566"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/pa.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.PA do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(9[134])([2-5|89].{7}|9[89].{7})$/ 7 | def area_name, do: "Pará" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "PA" 10 | 11 | matcher(["5591", "5593", "5594"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/pb.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.PB do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(83)([2-5|89].{7}|9[89].{7})$/ 7 | def area_name, do: "Paraíba" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "PB" 10 | 11 | matcher(["5583"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/pe.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.PE do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(8[17])([2-5|89].{7}|9[89].{7})$/ 7 | def area_name, do: "Pernambuco" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "PE" 10 | 11 | matcher(["5581", "5587"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/pi.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.PI do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(8[69])([2-5|89].{7}|9[89].{7})/ 7 | def area_name, do: "Piauí" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "PI" 10 | 11 | matcher(["5586", "5589"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/pr.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.PR do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(4[1-6])([2-5|89].{7}|9[89].{7}|78.{6})$/ 7 | def area_name, do: "Paraná" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "PR" 10 | 11 | matcher(["5541", "5542", "5543", "5544", "5545", "5546"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/rj.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.RJ do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(2[124])([2-5|89].{7}|9.{8}|7[078].{6})$/ 7 | def area_name, do: "Rio de Janeiro" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "RJ" 10 | 11 | matcher(["5521", "5522", "5524"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/rn.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.RN do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(84)([2-5|89].{7}|9[89].{7})$/ 7 | def area_name, do: "Rio Grande do Norte" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "RN" 10 | 11 | matcher(["5584"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/ro.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.RO do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(69)([2-5|89].{7}|9[89].{7})$/ 7 | def area_name, do: "Rondônia" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "RO" 10 | 11 | matcher(["5569"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/rr.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.RR do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(95)([2-5|89].{7}|9[89].{7})$/ 7 | def area_name, do: "Roraima" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "RR" 10 | 11 | matcher(["5595"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/rs.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.RS do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(5[1|3-5])([2-5|89].{7}|9[89].{7}|78.{6})$/ 7 | def area_name, do: "Rio Grande do Sul" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "RS" 10 | 11 | matcher(["5551", "5553", "5554", "5555"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/sc.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.SC do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(4[7-9])([2-5|89].{7}|9[89].{7}|78.{6})$/ 7 | def area_name, do: "Santa Catarina" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "SC" 10 | 11 | matcher(["5547", "5548", "5549"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/se.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.SE do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(79)([2-5|89].{7}|9[89].{7})$/ 7 | def area_name, do: "Sergipe" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "SE" 10 | 11 | matcher(["5579"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/sp.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.SP do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(1[1-9])([2-5|89].{7}|9.{8}|7[07-9].{6})$/ 7 | def area_name, do: "São Paulo" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "SP" 10 | 11 | matcher(["5511", "5512", "5513", "5514", "5515", "5516", "5517", "5518", "5519"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/to.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.TO do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(55)(63)([2-5|89].{7}|9[89].{7})$/ 7 | def area_name, do: "Tocantins" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "TO" 10 | 11 | matcher(["5563"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/br/toll_free.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BR.TollFree do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(55)(800)([0-9].{6,7})$/ 7 | def country, do: "Brazil toll-free" 8 | def a2, do: "BR" 9 | def a3, do: "BRA" 10 | 11 | matcher(:regex, ["55800"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/bt.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BT do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(975)()(.{7,8})/ 7 | def country, do: "Bhutan" 8 | def a2, do: "BT" 9 | def a3, do: "BTN" 10 | 11 | matcher(:regex, ["975"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/bw.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BW do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(267)()(.{7})/ 7 | def country, do: "Botswana" 8 | def a2, do: "BW" 9 | def a3, do: "BWA" 10 | 11 | matcher(:regex, ["267"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/by.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BY do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(375)()(.{9})/ 7 | def country, do: "Belarus" 8 | def a2, do: "BY" 9 | def a3, do: "BLR" 10 | 11 | matcher(:regex, ["375"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/bz.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.BZ do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(501)()(.{7})/ 7 | def country, do: "Belize" 8 | def a2, do: "BZ" 9 | def a3, do: "BLZ" 10 | 11 | matcher(:regex, ["501"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/cd.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.CD do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(243)(.)(.{7})/ 7 | def country, do: "Democratic Republic of Congo" 8 | def a2, do: "CD" 9 | def a3, do: "COD" 10 | 11 | matcher(:regex, ["243"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/cf.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.CF do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(236)()(.{8})/ 7 | def country, do: "Central African Republic" 8 | def a2, do: "CF" 9 | def a3, do: "CAF" 10 | 11 | matcher(:regex, ["236"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/cg.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.CG do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(242)(.{4})(.{5})/ 7 | def country, do: "Congo" 8 | def a2, do: "CG" 9 | def a3, do: "COG" 10 | 11 | matcher(:regex, ["242"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ch.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.CH do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(41)()(.{9,10})/ 7 | def country, do: "Switzerland" 8 | def a2, do: "CH" 9 | def a3, do: "CHE" 10 | 11 | matcher(:regex, ["41"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ci.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.CI do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(225)(..)(.{6})/ 7 | def country, do: "Ivory Coast" 8 | def a2, do: "CI" 9 | def a3, do: "CIV" 10 | 11 | matcher(:regex, ["225"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ck.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.CK do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(682)()(.{5})/ 7 | def country, do: "Cook Islands" 8 | def a2, do: "CK" 9 | def a3, do: "COK" 10 | 11 | matcher(:regex, ["682"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/cl.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.CL do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(56)()(.{9})/ 7 | def country, do: "Chile" 8 | def a2, do: "CL" 9 | def a3, do: "CHL" 10 | 11 | matcher(:regex, ["56"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/cm.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.CM do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(237)()(.{8})/ 7 | def country, do: "Cameroon" 8 | def a2, do: "CM" 9 | def a3, do: "CMR" 10 | 11 | matcher(:regex, ["237"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/cn.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.CN do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(86)()(.+)/ 7 | def country, do: "China" 8 | def a2, do: "CN" 9 | def a3, do: "CHN" 10 | 11 | matcher(:regex, ["86"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/co.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.CO do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(57)()(.+)/ 7 | def country, do: "Colombia" 8 | def a2, do: "CO" 9 | def a3, do: "COL" 10 | 11 | matcher(:regex, ["57"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/cr.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.CR do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(506)()(.{8})/ 7 | def country, do: "Costa Rica" 8 | def a2, do: "CR" 9 | def a3, do: "CRI" 10 | 11 | matcher(:regex, ["506"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/cu.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.CU do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(53)()(.{8})/ 7 | def country, do: "Cuba" 8 | def a2, do: "CU" 9 | def a3, do: "CUB" 10 | 11 | matcher(:regex, ["53"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/cv.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.CV do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(238)()(.{7})/ 7 | def country, do: "Cape Verde" 8 | def a2, do: "CV" 9 | def a3, do: "CPV" 10 | 11 | matcher(:regex, ["238"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/cw.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.CW do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(599)(9)(.{7})/ 7 | def country, do: "Curaçao" 8 | def a2, do: "CW" 9 | def a3, do: "CUW" 10 | 11 | matcher(:regex, ["5999"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/cy.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.CY do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(357)()(.{7,8})/ 7 | def country, do: "Cyprus" 8 | def a2, do: "CY" 9 | def a3, do: "CYP" 10 | 11 | matcher(:regex, ["357"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/cz.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.CZ do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(420)()(.{9})/ 7 | def country, do: "Czech Republic" 8 | def a2, do: "CZ" 9 | def a3, do: "CZE" 10 | 11 | matcher(:regex, ["420"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/de.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.DE do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(49)()(.{8,11})/ 7 | def country, do: "Germany" 8 | def a2, do: "DE" 9 | def a3, do: "DEU" 10 | 11 | matcher(:regex, ["49"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/dj.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.DJ do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(253)()(.{8})/ 7 | def country, do: "Djibouti" 8 | def a2, do: "DJ" 9 | def a3, do: "DJI" 10 | 11 | matcher(:regex, ["253"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/dk.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.DK do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(45)()(.{8})/ 7 | def country, do: "Denmark" 8 | def a2, do: "DK" 9 | def a3, do: "DNK" 10 | 11 | matcher(:regex, ["45"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/dz.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.DZ do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(213)()(.{8})/ 7 | def country, do: "Algeria" 8 | def a2, do: "DZ" 9 | def a3, do: "DZA" 10 | 11 | matcher(:regex, ["213"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ec.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.EC do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(593)(..)(.{7})/ 7 | def country, do: "Ecuador" 8 | def a2, do: "EC" 9 | def a3, do: "ECU" 10 | 11 | matcher(:regex, ["593"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ee.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.EE do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(372)()(.{7,8})/ 7 | def country, do: "Estonia" 8 | def a2, do: "EE" 9 | def a3, do: "EST" 10 | 11 | matcher(:regex, ["372"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/eg.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.EG do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(20)()(.+)/ 7 | def country, do: "Egypt" 8 | def a2, do: "EG" 9 | def a3, do: "EGY" 10 | 11 | matcher(:regex, ["20"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/er.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ER do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(291)(.)(.{6})/ 7 | def country, do: "Eritrea" 8 | def a2, do: "ER" 9 | def a3, do: "ERI" 10 | 11 | matcher(:regex, ["291"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES do 2 | @moduledoc false 3 | use Helper.Country 4 | 5 | def country, do: "Spain" 6 | def a2, do: "ES" 7 | def a3, do: "ESP" 8 | 9 | matcher(:modules, [ 10 | Phone.ES.A, 11 | Phone.ES.AB, 12 | Phone.ES.AL, 13 | Phone.ES.AV, 14 | Phone.ES.B, 15 | Phone.ES.BA, 16 | Phone.ES.BI, 17 | Phone.ES.BU, 18 | Phone.ES.C, 19 | Phone.ES.CA, 20 | Phone.ES.CC, 21 | Phone.ES.CO, 22 | Phone.ES.CR, 23 | Phone.ES.CS, 24 | Phone.ES.CU, 25 | Phone.ES.GC, 26 | Phone.ES.GI, 27 | Phone.ES.GR, 28 | Phone.ES.GU, 29 | Phone.ES.H, 30 | Phone.ES.HU, 31 | Phone.ES.J, 32 | Phone.ES.L, 33 | Phone.ES.LE, 34 | Phone.ES.LO, 35 | Phone.ES.LU, 36 | Phone.ES.M, 37 | Phone.ES.MA, 38 | Phone.ES.MU, 39 | Phone.ES.NA, 40 | Phone.ES.O, 41 | Phone.ES.OR, 42 | Phone.ES.P, 43 | Phone.ES.PM, 44 | Phone.ES.PO, 45 | Phone.ES.S, 46 | Phone.ES.SA, 47 | Phone.ES.SE, 48 | Phone.ES.SG, 49 | Phone.ES.SO, 50 | Phone.ES.SS, 51 | Phone.ES.T, 52 | Phone.ES.TE, 53 | Phone.ES.TF, 54 | Phone.ES.TO, 55 | Phone.ES.V, 56 | Phone.ES.VA, 57 | Phone.ES.VI, 58 | Phone.ES.Z, 59 | Phone.ES.ZA 60 | ]) 61 | end 62 | -------------------------------------------------------------------------------- /lib/phone/es/a.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.A do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(96[5-6]|86[5-6])(.{6})$/ 7 | def area_name, do: "Alicante" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "A" 10 | 11 | matcher(["34965", "34966", "34865", "34866"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/ab.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.AB do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(967|867)(.{6})$/ 7 | def area_name, do: "Albacete" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "AB" 10 | 11 | matcher(["34967", "34867"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/al.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.AL do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(950|850)(.{6})$/ 7 | def area_name, do: "Almería" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "AL" 10 | 11 | matcher(["34950", "34850"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/av.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.AV do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(920|820)(.{6})$/ 7 | def area_name, do: "Ávila" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "AV" 10 | 11 | matcher(["34920", "34820"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/b.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.B do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(93[0-9]|83[0-9])(.{6})$/ 7 | def area_name, do: "Barcelona" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "B" 10 | 11 | matcher([ 12 | "34930", 13 | "34931", 14 | "34932", 15 | "34933", 16 | "34934", 17 | "34935", 18 | "34936", 19 | "34937", 20 | "34938", 21 | "34939", 22 | "34830", 23 | "34831", 24 | "34832", 25 | "34833", 26 | "34834", 27 | "34835", 28 | "34836", 29 | "34837", 30 | "34838", 31 | "34839" 32 | ]) 33 | end 34 | -------------------------------------------------------------------------------- /lib/phone/es/ba.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.BA do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(924|824)(.{6})$/ 7 | def area_name, do: "Badajoz" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "BA" 10 | 11 | matcher(["34924", "34824"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/bi.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.BI do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(944|946|844|846)(.{6})$/ 7 | def area_name, do: "Bizkaia" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "BI" 10 | 11 | matcher(["34944", "34946", "34844", "34846"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/bu.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.BU do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(947|847)(.{6})$/ 7 | def area_name, do: "Burgos" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "BU" 10 | 11 | matcher(["34947", "34847"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/c.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.C do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(981|881)(.{6})$/ 7 | def area_name, do: "A Coruña" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "C" 10 | 11 | matcher(["34981", "34881"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/ca.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.CA do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(956|856)(.{6})$/ 7 | def area_name, do: "Cádiz" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "CA" 10 | 11 | matcher(["34956", "34856"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/cc.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.CC do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(927|827)(.{6})$/ 7 | def area_name, do: "Cáceres" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "CC" 10 | 11 | matcher(["34927", "34827"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/co.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.CO do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(957|857)(.{6})$/ 7 | def area_name, do: "Córdoba" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "CO" 10 | 11 | matcher(["34957", "34857"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/cr.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.CR do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(926|826)(.{6})$/ 7 | def area_name, do: "Ciudad Real" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "CR" 10 | 11 | matcher(["34926", "34826"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/cs.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.CS do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(964|864)(.{6})$/ 7 | def area_name, do: "Castellón" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "CS" 10 | 11 | matcher(["34964", "34864"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/cu.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.CU do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(969|869)(.{6})$/ 7 | def area_name, do: "Cuenca" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "CU" 10 | 11 | matcher(["34969", "34869"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/gc.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.GC do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(928|828)(.{6})$/ 7 | def area_name, do: "Las Palmas" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "GC" 10 | 11 | matcher(["34928", "34828"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/gi.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.GI do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(972|872)(.{6})$/ 7 | def area_name, do: "Girona" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "GI" 10 | 11 | matcher(["34972", "34872"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/gr.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.GR do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(958|858)(.{6})$/ 7 | def area_name, do: "Granada" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "GR" 10 | 11 | matcher(["34958", "34858"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/gu.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.GU do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(949|849)(.{6})$/ 7 | def area_name, do: "Guadalajara" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "GU" 10 | 11 | matcher(["34949", "34849"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/h.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.H do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(959|859)(.{6})$/ 7 | def area_name, do: "Huelva" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "H" 10 | 11 | matcher(["34959", "34859"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/hu.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.HU do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(974|874)(.{6})$/ 7 | def area_name, do: "Huesca" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "HU" 10 | 11 | matcher(["34974", "34874"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/intelligent_numbers.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.IntelligentNumbers do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(34)(90[0-2]|905|800|803|80[6-7]|70[0-9])(.{6})$/ 7 | def country, do: "Spain intelligent-number" 8 | def a2, do: "ES" 9 | def a3, do: "ESP" 10 | 11 | matcher(:regex, [ 12 | "34900", 13 | "34901", 14 | "34902", 15 | "34905", 16 | "34800", 17 | "34803", 18 | "34806", 19 | "34807", 20 | "34700", 21 | "34701", 22 | "34702", 23 | "34703", 24 | "34704", 25 | "34705", 26 | "34706", 27 | "34707", 28 | "34708", 29 | "34709" 30 | ]) 31 | end 32 | -------------------------------------------------------------------------------- /lib/phone/es/j.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.J do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(953|853)(.{6})$/ 7 | def area_name, do: "Jaen" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "J" 10 | 11 | matcher(["34953", "34853"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/l.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.L do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(973|873)(.{6})$/ 7 | def area_name, do: "Lleida" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "L" 10 | 11 | matcher(["34973", "34873"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/le.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.LE do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(987|887)(.{6})$/ 7 | def area_name, do: "León" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "LE" 10 | 11 | matcher(["34987", "34887"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/lo.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.LO do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(941|841)(.{6})$/ 7 | def area_name, do: "La Rioja" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "LO" 10 | 11 | matcher(["34941", "34841"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/lu.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.LU do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(982|882)(.{6})$/ 7 | def area_name, do: "Lugo" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "LU" 10 | 11 | matcher(["34982", "34882"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/m.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.M do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(91[0-9]|81[0-9])(.{6})$/ 7 | def area_name, do: "Comunidad de Madrid" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "M" 10 | 11 | matcher([ 12 | "34910", 13 | "34911", 14 | "34912", 15 | "34913", 16 | "34914", 17 | "34915", 18 | "34916", 19 | "34917", 20 | "34918", 21 | "34919", 22 | "34810", 23 | "34811", 24 | "34812", 25 | "34813", 26 | "34814", 27 | "34815", 28 | "34816", 29 | "34817", 30 | "34818", 31 | "34819" 32 | ]) 33 | end 34 | -------------------------------------------------------------------------------- /lib/phone/es/ma.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.MA do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(95[1-2]|85[1-2])(.{6})$/ 7 | def area_name, do: "Málaga" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "MA" 10 | 11 | matcher(["34951", "34952", "34851", "34852"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/mobile.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.Mobile do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(34)(6[0-9]|7[1-4])(.{7})$/ 7 | def country, do: "Spain Mobile" 8 | def a2, do: "ES" 9 | def a3, do: "ESP" 10 | 11 | matcher(:regex, [ 12 | "3460", 13 | "3461", 14 | "3462", 15 | "3463", 16 | "3464", 17 | "3465", 18 | "3466", 19 | "3467", 20 | "3468", 21 | "3469", 22 | "3471", 23 | "3472", 24 | "3473", 25 | "3474" 26 | ]) 27 | end 28 | -------------------------------------------------------------------------------- /lib/phone/es/mu.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.MU do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(968|868)(.{6})$/ 7 | def area_name, do: "Murcia" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "MU" 10 | 11 | matcher(["34968", "34868"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/na.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.NA do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(948|848)(.{6})$/ 7 | def area_name, do: "Navarra" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "NA" 10 | 11 | matcher(["34948", "34848"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/o.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.O do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(98[4-5]|88[4-5])(.{6})$/ 7 | def area_name, do: "Asturias" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "O" 10 | 11 | matcher(["34984", "34985", "34884", "34885"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/or.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.OR do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(988|888)(.{6})$/ 7 | def area_name, do: "Ourense" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "OR" 10 | 11 | matcher(["34988", "34888"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/p.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.P do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(979|879)(.{6})$/ 7 | def area_name, do: "Palencia" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "P" 10 | 11 | matcher(["34979", "34879"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/pm.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.PM do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(971|871)(.{6})$/ 7 | def area_name, do: "Illes Balears" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "PM" 10 | 11 | matcher(["34971", "34871"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/po.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.PO do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(986|886)(.{6})$/ 7 | def area_name, do: "Pontevedra" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "PO" 10 | 11 | matcher(["34986", "34886"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/s.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.S do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(942|842)(.{6})$/ 7 | def area_name, do: "Cantabria" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "S" 10 | 11 | matcher(["34942", "34842"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/sa.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.SA do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(923|823)(.{6})$/ 7 | def area_name, do: "Salamanca" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "SA" 10 | 11 | matcher(["34923", "34823"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/se.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.SE do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(95[4-5]|85[4-5])(.{6})$/ 7 | def area_name, do: "Sevilla" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "SE" 10 | 11 | matcher(["34954", "34955", "34854", "34855"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/sg.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.SG do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(921|821)(.{6})$/ 7 | def area_name, do: "Segovia" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "SG" 10 | 11 | matcher(["34921", "34821"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/so.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.SO do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(975|875)(.{6})$/ 7 | def area_name, do: "Soria" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "SO" 10 | 11 | matcher(["34975", "34875"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/ss.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.SS do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(943|843)(.{6})$/ 7 | def area_name, do: "Guipúzcoa" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "SS" 10 | 11 | matcher(["34943", "34843"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/t.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.T do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(977|877)(.{6})$/ 7 | def area_name, do: "Tarragona" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "T" 10 | 11 | matcher(["34977", "34877"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/te.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.TE do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(978|878)(.{6})$/ 7 | def area_name, do: "Teruel" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "TE" 10 | 11 | matcher(["34978", "34878"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/tf.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.TF do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(922|822)(.{6})$/ 7 | def area_name, do: "Santa Cruz de Tenerife" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "TF" 10 | 11 | matcher(["34922", "34822"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/to.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.TO do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(925|825)(.{6})$/ 7 | def area_name, do: "Toledo" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "TO" 10 | 11 | matcher(["34925", "34825"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/v.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.V do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(96[0-3]|86[0-3])(.{6})$/ 7 | def area_name, do: "Valencia" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "V" 10 | 11 | matcher([ 12 | "34960", 13 | "34961", 14 | "34962", 15 | "34963", 16 | "34860", 17 | "34861", 18 | "34862", 19 | "34863" 20 | ]) 21 | end 22 | -------------------------------------------------------------------------------- /lib/phone/es/va.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.VA do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(983|883)(.{6})$/ 7 | def area_name, do: "Valladolid" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "VA" 10 | 11 | matcher(["34983", "34883"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/vi.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.VI do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(945|845)(.{6})$/ 7 | def area_name, do: "Álava" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "VI" 10 | 11 | matcher(["34945", "34845"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/z.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.Z do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(976|876)(.{6})$/ 7 | def area_name, do: "Zaragoza" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "Z" 10 | 11 | matcher(["34976", "34876"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/es/za.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ES.ZA do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(34)(980|880)(.{6})$/ 7 | def area_name, do: "Zamora" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "ZA" 10 | 11 | matcher(["34980", "34880"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/et.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ET do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(251)(..)(.{7})/ 7 | def country, do: "Ethiopia" 8 | def a2, do: "ET" 9 | def a3, do: "ETH" 10 | 11 | matcher(:regex, ["251"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/fi.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.FI do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(358)()(.+)/ 7 | def country, do: "Finland" 8 | def a2, do: "FI" 9 | def a3, do: "FIN" 10 | 11 | matcher(:regex, ["358"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/fj.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.FJ do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(679)()(.{7})/ 7 | def country, do: "Fiji" 8 | def a2, do: "FJ" 9 | def a3, do: "FJI" 10 | 11 | matcher(:regex, ["679"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/fm.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.FM do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(691)()(.{7})/ 7 | def country, do: "Micronesia" 8 | def a2, do: "FM" 9 | def a3, do: "FSM" 10 | 11 | matcher(:regex, ["691"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/fo.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.FO do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(298)()(.{6})/ 7 | def country, do: "Faroe Islands" 8 | def a2, do: "FO" 9 | def a3, do: "FRO" 10 | 11 | matcher(:regex, ["298"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/fr.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.FR do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(33)()(.{9})/ 7 | def country, do: "France" 8 | def a2, do: "FR" 9 | def a3, do: "FRA" 10 | 11 | matcher(:regex, ["33"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ga.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.GA do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(241)()(.{7})/ 7 | def country, do: "Gabon" 8 | def a2, do: "GA" 9 | def a3, do: "GAB" 10 | 11 | matcher(:regex, ["241"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/gb.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.GB do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(44)()(.{10})/ 7 | def country, do: "United Kingdom" 8 | def a2, do: "GB" 9 | def a3, do: "GBR" 10 | 11 | matcher(:regex, ["44"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ge.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.GE do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(995)(.{3})(.{6})/ 7 | def country, do: "Georgia" 8 | def a2, do: "GE" 9 | def a3, do: "GEO" 10 | 11 | matcher(:regex, ["995"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/gf.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.GF do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(594)([5|6]94)(.{6})/ 7 | def country, do: "French Guiana" 8 | def a2, do: "GF" 9 | def a3, do: "GUF" 10 | 11 | matcher(:regex, ["594594", "594694"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/gh.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.GH do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(233)(..)(.{7})/ 7 | def country, do: "Ghana" 8 | def a2, do: "GH" 9 | def a3, do: "GHA" 10 | 11 | matcher(:regex, ["233"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/gi.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.GI do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(350)()(.{8})/ 7 | def country, do: "Gibraltar" 8 | def a2, do: "GI" 9 | def a3, do: "GIB" 10 | 11 | matcher(:regex, ["350"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/gl.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.GL do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(299)(..)(.{4})/ 7 | def country, do: "Greenland" 8 | def a2, do: "GL" 9 | def a3, do: "GRL" 10 | 11 | matcher(:regex, ["299"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/gm.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.GM do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(220)()(.{7})/ 7 | def country, do: "Gambia" 8 | def a2, do: "GM" 9 | def a3, do: "GMB" 10 | 11 | matcher(:regex, ["220"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/gn.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.GN do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(224)()(.{8})/ 7 | def country, do: "Guinea" 8 | def a2, do: "GN" 9 | def a3, do: "GIN" 10 | 11 | matcher(:regex, ["224"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/gp.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.GP do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(590)(.{3})(.{6})/ 7 | def country, do: "Guadeloupe" 8 | def a2, do: "GP" 9 | def a3, do: "GLP" 10 | 11 | matcher(:regex, ["590"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/gq.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.GQ do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(240)()(.{9})/ 7 | def country, do: "Equatorial Guinea" 8 | def a2, do: "GQ" 9 | def a3, do: "GNQ" 10 | 11 | matcher(:regex, ["240"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/gr.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.GR do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(30)()(.{10})/ 7 | def country, do: "Greece" 8 | def a2, do: "GR" 9 | def a3, do: "GRC" 10 | 11 | matcher(:regex, ["30"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/gt.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.GT do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(502)()(.{8})/ 7 | def country, do: "Guatemala" 8 | def a2, do: "GT" 9 | def a3, do: "GTM" 10 | 11 | matcher(:regex, ["502"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/gw.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.GW do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(245)()(.{7})/ 7 | def country, do: "Guinea-Bissau" 8 | def a2, do: "GW" 9 | def a3, do: "GNB" 10 | 11 | matcher(:regex, ["245"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/gy.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.GY do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(592)()(.{8})/ 7 | def country, do: "Guyana" 8 | def a2, do: "GY" 9 | def a3, do: "GUY" 10 | 11 | matcher(:regex, ["592"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/hk.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.HK do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(852)()(.{8})/ 7 | def country, do: "Hong Kong" 8 | def a2, do: "HK" 9 | def a3, do: "HKG" 10 | 11 | matcher(:regex, ["852"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/hn.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.HN do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(504)()(.{8})/ 7 | def country, do: "Honduras" 8 | def a2, do: "HN" 9 | def a3, do: "HND" 10 | 11 | matcher(:regex, ["504"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/hr.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.HR do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(385)()(.{8,9})/ 7 | def country, do: "Croatia" 8 | def a2, do: "HR" 9 | def a3, do: "HRV" 10 | 11 | matcher(:regex, ["385"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ht.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.HT do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(509)()(.{8})/ 7 | def country, do: "Haiti" 8 | def a2, do: "HT" 9 | def a3, do: "HTI" 10 | 11 | matcher(:regex, ["509"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/hu.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.HU do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(36)()(.{8,9})/ 7 | def country, do: "Hungary" 8 | def a2, do: "HU" 9 | def a3, do: "HUN" 10 | 11 | matcher(:regex, ["36"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/id.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ID do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(62)()(.+)/ 7 | def country, do: "Indonesia" 8 | def a2, do: "ID" 9 | def a3, do: "IDN" 10 | 11 | matcher(:regex, ["62"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ie.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.IE do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(353)(1|087|402|800|404|505|90|[2-9][1-9])(.{5,9})$/ 7 | def country, do: "Ireland" 8 | def a2, do: "IE" 9 | def a3, do: "IRL" 10 | 11 | matcher(:regex, ["353"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/il.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.IL do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(972)()(.{8,9})/ 7 | def country, do: "Israel" 8 | def a2, do: "IL" 9 | def a3, do: "ISR" 10 | 11 | matcher(:regex, ["972"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/in.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.IN do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(91)()(.+)/ 7 | def country, do: "India" 8 | def a2, do: "IN" 9 | def a3, do: "IND" 10 | 11 | matcher(:regex, ["91"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/io.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.IO do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(246)() (.{7})/ 7 | def country, do: "British Indian Ocean Territory" 8 | def a2, do: "IO" 9 | def a3, do: "IOT" 10 | 11 | matcher(:regex, ["246"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/iq.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.IQ do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(964)()(.+)/ 7 | def country, do: "Iraq" 8 | def a2, do: "IQ" 9 | def a3, do: "IRQ" 10 | 11 | matcher(:regex, ["964"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ir.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.IR do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(98)()(.+)/ 7 | def country, do: "Iran" 8 | def a2, do: "IR" 9 | def a3, do: "IRN" 10 | 11 | matcher(:regex, ["98"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/is.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.IS do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(354)()(.{7})/ 7 | def country, do: "Iceland" 8 | def a2, do: "IS" 9 | def a3, do: "ISL" 10 | 11 | matcher(:regex, ["354"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/it.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.IT do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(39)()(.{3,12})/ 7 | def country, do: "Italy" 8 | def a2, do: "IT" 9 | def a3, do: "ITA" 10 | 11 | matcher(:regex, ["39"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/jo.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.JO do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(962)(.)(.{7,8})/ 7 | def country, do: "Jordan" 8 | def a2, do: "JO" 9 | def a3, do: "JOR" 10 | 11 | matcher(:regex, ["962"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/jp.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.JP do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(81)()(.+)/ 7 | def country, do: "Japan" 8 | def a2, do: "JP" 9 | def a3, do: "JPN" 10 | 11 | matcher(:regex, ["81"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ke.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.KE do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(254)()(.+)/ 7 | def country, do: "Kenya" 8 | def a2, do: "KE" 9 | def a3, do: "KEN" 10 | 11 | matcher(:regex, ["254"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/kg.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.KG do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(996)()(.{9})/ 7 | def country, do: "Kyrgyzstan" 8 | def a2, do: "KG" 9 | def a3, do: "KGZ" 10 | 11 | matcher(:regex, ["996"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/kh.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.KH do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(855)(..)(.{6,7})/ 7 | def country, do: "Cambodia" 8 | def a2, do: "KH" 9 | def a3, do: "KHM" 10 | 11 | matcher(:regex, ["855"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ki.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.KI do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(686)()(.{5})/ 7 | def country, do: "Kiribati" 8 | def a2, do: "KI" 9 | def a3, do: "KIR" 10 | 11 | matcher(:regex, ["686"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/km.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.KM do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(269)(.{3})(.{4})/ 7 | def country, do: "Comoros" 8 | def a2, do: "KM" 9 | def a3, do: "COM" 10 | 11 | matcher(:regex, ["269"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/kp.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.KP do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(850)()(.+)/ 7 | def country, do: "North Korea" 8 | def a2, do: "KP" 9 | def a3, do: "PRK" 10 | 11 | matcher(:regex, ["850"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/kr.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.KR do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(82)(.{1,2})(.{7,8})/ 7 | def country, do: "South Korea" 8 | def a2, do: "KR" 9 | def a3, do: "KOR" 10 | 11 | matcher(:regex, ["82"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/kw.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.KW do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(965)()(.{8})/ 7 | def country, do: "Kuwait" 8 | def a2, do: "KW" 9 | def a3, do: "KWT" 10 | 11 | matcher(:regex, ["965"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/kz.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.KZ do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(7)([67]..)(.{7})/ 7 | def country, do: "Kazakhstan" 8 | def a2, do: "KZ" 9 | def a3, do: "KAZ" 10 | 11 | matcher(:regex, ["76", "77"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/la.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.LA do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(856)(..)(.+)/ 7 | def country, do: "Laos" 8 | def a2, do: "LA" 9 | def a3, do: "LAO" 10 | 11 | matcher(:regex, ["856"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/lb.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.LB do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(961)(.{1,2})(.{6})/ 7 | def country, do: "Lebanon" 8 | def a2, do: "LB" 9 | def a3, do: "LBN" 10 | 11 | matcher(:regex, ["961"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/li.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.LI do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(423)()(.{7})/ 7 | def country, do: "Liechtenstein" 8 | def a2, do: "LI" 9 | def a3, do: "LIE" 10 | 11 | matcher(:regex, ["423"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/lk.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.LK do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(94)()(.{9})/ 7 | def country, do: "Sri Lanka" 8 | def a2, do: "LK" 9 | def a3, do: "LKA" 10 | 11 | matcher(:regex, ["94"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/lr.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.LR do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(231)()(.{7,9})/ 7 | def country, do: "Liberia" 8 | def a2, do: "LR" 9 | def a3, do: "LBR" 10 | 11 | matcher(:regex, ["231"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ls.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.LS do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(266)(..)(.{6})/ 7 | def country, do: "Lesotho" 8 | def a2, do: "LS" 9 | def a3, do: "LSO" 10 | 11 | matcher(:regex, ["266"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/lt.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.LT do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(370)()(.{8})/ 7 | def country, do: "Lithuania" 8 | def a2, do: "LT" 9 | def a3, do: "LTU" 10 | 11 | matcher(:regex, ["370"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/lu.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.LU do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(352)()(.+)/ 7 | def country, do: "Luxembourg" 8 | def a2, do: "LU" 9 | def a3, do: "LUX" 10 | 11 | matcher(:regex, ["352"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/lv.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.LV do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(371)()(.{8})/ 7 | def country, do: "Latvia" 8 | def a2, do: "LV" 9 | def a3, do: "LVA" 10 | 11 | matcher(:regex, ["371"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ly.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.LY do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(218)()(.+)/ 7 | def country, do: "Libya" 8 | def a2, do: "LY" 9 | def a3, do: "LBY" 10 | 11 | matcher(:regex, ["218"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ma.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.MA do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(212)()(.{9})/ 7 | def country, do: "Morocco" 8 | def a2, do: "MA" 9 | def a3, do: "MAR" 10 | 11 | matcher(:regex, ["212"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/mc.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.MC do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(377)()(.{8})/ 7 | def country, do: "Monaco" 8 | def a2, do: "MC" 9 | def a3, do: "MCO" 10 | 11 | matcher(:regex, ["377"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/md.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.MD do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(373)()(.{8})/ 7 | def country, do: "Moldova" 8 | def a2, do: "MD" 9 | def a3, do: "MDA" 10 | 11 | matcher(:regex, ["373"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/me.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ME do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(382)(..)(.{6})/ 7 | def country, do: "Montenegro" 8 | def a2, do: "ME" 9 | def a3, do: "MNE" 10 | 11 | matcher(:regex, ["382"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/mg.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.MG do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(261)()(.+)/ 7 | def country, do: "Madagascar" 8 | def a2, do: "MG" 9 | def a3, do: "MDG" 10 | 11 | matcher(:regex, ["261"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/mh.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.MH do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(692)()(.{6,7})/ 7 | def country, do: "Marshall Islands" 8 | def a2, do: "MH" 9 | def a3, do: "MHL" 10 | 11 | matcher(:regex, ["692"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/mk.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.MK do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(389)()(.{8})/ 7 | def country, do: "Macedonia" 8 | def a2, do: "MK" 9 | def a3, do: "MKD" 10 | 11 | matcher(:regex, ["389"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ml.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ML do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(223)()(.{8})/ 7 | def country, do: "Mali" 8 | def a2, do: "ML" 9 | def a3, do: "MLI" 10 | 11 | matcher(:regex, ["223"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/mm.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.MM do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(95)()(.{7,10})/ 7 | def country, do: "Myanmar" 8 | def a2, do: "MM" 9 | def a3, do: "MMR" 10 | 11 | matcher(:regex, ["95"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/mn.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.MN do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(976)()(.+)/ 7 | def country, do: "Mongolia" 8 | def a2, do: "MN" 9 | def a3, do: "MNG" 10 | 11 | matcher(:regex, ["976"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/mo.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.MO do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(853)()(.{8})/ 7 | def country, do: "Macao" 8 | def a2, do: "MO" 9 | def a3, do: "MAC" 10 | 11 | matcher(:regex, ["853"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/mq.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.MQ do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(596)([5|6]96)(.{6})/ 7 | def country, do: "Martinique" 8 | def a2, do: "MQ" 9 | def a3, do: "MTQ" 10 | 11 | matcher(:regex, ["596596", "596696"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/mr.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.MR do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(222)()(.{8})/ 7 | def country, do: "Mauritania" 8 | def a2, do: "MR" 9 | def a3, do: "MRT" 10 | 11 | matcher(:regex, ["222"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/mt.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.MT do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(356)()(.{8})/ 7 | def country, do: "Malta" 8 | def a2, do: "MT" 9 | def a3, do: "MLT" 10 | 11 | matcher(:regex, ["356"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/mu.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.MU do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(230)()(.{8})/ 7 | def country, do: "Mauritius" 8 | def a2, do: "MU" 9 | def a3, do: "MUS" 10 | 11 | matcher(:regex, ["230"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/mv.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.MV do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(960)()(.{7})/ 7 | def country, do: "Maldives" 8 | def a2, do: "MV" 9 | def a3, do: "MDV" 10 | 11 | matcher(:regex, ["960"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/mw.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.MW do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(265)()(.{7,9})/ 7 | def country, do: "Malawi" 8 | def a2, do: "MW" 9 | def a3, do: "MWI" 10 | 11 | matcher(:regex, ["265"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/mx.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.MX do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(52)()(.{10})/ 7 | def country, do: "Mexico" 8 | def a2, do: "MX" 9 | def a3, do: "MEX" 10 | 11 | matcher(:regex, ["52"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/my.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.MY do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(60)()(.+)/ 7 | def country, do: "Malaysia" 8 | def a2, do: "MY" 9 | def a3, do: "MYS" 10 | 11 | matcher(:regex, ["60"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/mz.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.MZ do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(258)()(.+)/ 7 | def country, do: "Mozambique" 8 | def a2, do: "MZ" 9 | def a3, do: "MOZ" 10 | 11 | matcher(:regex, ["258"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/na.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NA do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(264)()(.+)/ 7 | def country, do: "Namibia" 8 | def a2, do: "NA" 9 | def a3, do: "NAM" 10 | 11 | matcher(:regex, ["264"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | matcher(:modules, [ 7 | Phone.NANP.AS, 8 | Phone.NANP.AI, 9 | Phone.NANP.AG, 10 | Phone.NANP.BS, 11 | Phone.NANP.BB, 12 | Phone.NANP.BM, 13 | Phone.NANP.CA, 14 | Phone.NANP.DM, 15 | Phone.NANP.DO, 16 | Phone.NANP.GD, 17 | Phone.NANP.GU, 18 | Phone.NANP.JM, 19 | Phone.NANP.KN, 20 | Phone.NANP.KY, 21 | Phone.NANP.LC, 22 | Phone.NANP.MP, 23 | Phone.NANP.MS, 24 | Phone.NANP.PR, 25 | Phone.NANP.SX, 26 | Phone.NANP.TC, 27 | Phone.NANP.TT, 28 | Phone.NANP.US, 29 | Phone.NANP.VC, 30 | Phone.NANP.VG, 31 | Phone.NANP.VI, 32 | Phone.NANP.TollFree 33 | ]) 34 | end 35 | -------------------------------------------------------------------------------- /lib/phone/nanp/ag.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.AG do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(268)([2-9].{6})$/ 7 | def country, do: "Antigua and Barbuda" 8 | def a2, do: "AG" 9 | def a3, do: "ATG" 10 | 11 | matcher(:regex, ["1268"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/ai.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.AI do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(264)([2-9].{6})$/ 7 | def country, do: "Anguilla" 8 | def a2, do: "AI" 9 | def a3, do: "AIA" 10 | 11 | matcher(:regex, ["1264"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/as.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.AS do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(684)([2-9].{6})$/ 7 | def country, do: "American Samoa" 8 | def a2, do: "AS" 9 | def a3, do: "ASM" 10 | 11 | matcher(:regex, ["1684"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/bb.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.BB do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(246)([2-9].{6})$/ 7 | def country, do: "Barbados" 8 | def a2, do: "BB" 9 | def a3, do: "BRB" 10 | 11 | matcher(:regex, ["1246"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/bm.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.BM do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(441)([2-9].{6})$/ 7 | def country, do: "Bermuda" 8 | def a2, do: "BM" 9 | def a3, do: "BMU" 10 | 11 | matcher(:regex, ["1441"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/bs.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.BS do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(242)([2-9].{6})$/ 7 | def country, do: "Bahamas" 8 | def a2, do: "BS" 9 | def a3, do: "BHS" 10 | 11 | matcher(:regex, ["1242"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/ca.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.CA do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def country, do: "Canada" 7 | def a2, do: "CA" 8 | def a3, do: "CAN" 9 | 10 | matcher(:modules, [ 11 | Phone.NANP.CA.AB, 12 | Phone.NANP.CA.BC, 13 | Phone.NANP.CA.MB, 14 | Phone.NANP.CA.NB, 15 | Phone.NANP.CA.NL, 16 | Phone.NANP.CA.NSAndPE, 17 | Phone.NANP.CA.ON, 18 | Phone.NANP.CA.QC, 19 | Phone.NANP.CA.SK, 20 | Phone.NANP.CA.Territory 21 | ]) 22 | end 23 | -------------------------------------------------------------------------------- /lib/phone/nanp/ca/ab.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.CA.AB do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(403|780|587|825)([2-9].{6})$/ 7 | def area_name, do: "Alberta" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "AB" 10 | 11 | matcher(["1403", "1780", "1587", "1825"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/ca/bc.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.CA.BC do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(604|778|236|250|672)([2-9].{6})$/ 7 | def area_name, do: "British Columbia" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "BC" 10 | 11 | matcher(["1604", "1778", "1236", "1250", "1672"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/ca/mb.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.CA.MB do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(204|431)([2-9].{6})$/ 7 | def area_name, do: "Manitoba" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "MB" 10 | 11 | matcher(["1204", "1431"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/ca/nb.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.CA.NB do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(506)([2-9].{6})$/ 7 | def area_name, do: "New Brunswick" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "NB" 10 | 11 | matcher(["1506"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/ca/nl.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.CA.NL do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(709)([2-9].{6})$/ 7 | def area_name, do: "Newfoundland and Labrador" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "NL" 10 | 11 | matcher(["1709"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/ca/ns_and_pe.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.CA.NSAndPE do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(902|782)([2-9].{6})$/ 7 | def area_name, do: ["Nova Scotia", "Prince Edward Island"] 8 | def area_type, do: "provinces" 9 | def area_abbreviation, do: ["NS", "PE"] 10 | 11 | matcher(["1902", "1782"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/ca/on.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.CA.ON do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(226|249|289|343|365|416|437|519|548|613|647|705|807|905)([2-9].{6})$/ 7 | def area_name, do: "Ontario" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "ON" 10 | 11 | matcher([ 12 | "1226", 13 | "1249", 14 | "1289", 15 | "1343", 16 | "1365", 17 | "1416", 18 | "1437", 19 | "1519", 20 | "1548", 21 | "1613", 22 | "1647", 23 | "1705", 24 | "1807", 25 | "1905" 26 | ]) 27 | end 28 | -------------------------------------------------------------------------------- /lib/phone/nanp/ca/qc.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.CA.QC do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(418|438|450|514|579|581|819|873)([2-9].{6})$/ 7 | def area_name, do: "Quebec" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "QC" 10 | 11 | matcher(["1418", "1438", "1450", "1514", "1579", "1581", "1819", "1873"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/ca/sk.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.CA.SK do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(306|639)([2-9].{6})$/ 7 | def area_name, do: "Saskatchewan" 8 | def area_type, do: "province" 9 | def area_abbreviation, do: "SK" 10 | 11 | matcher(["1306", "1639"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/ca/territory.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.CA.Territory do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(867)([2-9].{6})$/ 7 | def area_name, do: ["Northwest Territories", "Nunavut", "Yukon"] 8 | def area_type, do: "territories" 9 | def area_abbreviation, do: ["NT", "NU", "YT"] 10 | 11 | matcher(["1867"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/dm.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.DM do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(767)([2-9].{6})$/ 7 | def country, do: "Dominica" 8 | def a2, do: "DM" 9 | def a3, do: "DMA" 10 | 11 | matcher(:regex, ["1767"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/do.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.DO do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(8[0|2|4]9)([2-9].{6})$/ 7 | def country, do: "Dominican Republic" 8 | def a2, do: "DO" 9 | def a3, do: "DOM" 10 | 11 | matcher(:regex, ["1809", "1829", "1849"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/gd.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.GD do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(473)([2-9].{6})$/ 7 | def country, do: "Grenada" 8 | def a2, do: "GD" 9 | def a3, do: "GRD" 10 | 11 | matcher(:regex, ["1473"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/gu.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.GU do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(671)([2-9].{6})$/ 7 | def country, do: "Guam" 8 | def a2, do: "GU" 9 | def a3, do: "GUM" 10 | 11 | matcher(:regex, ["1671"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/jm.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.JM do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(658|876)([2-9].{6})$/ 7 | def country, do: "Jamaica" 8 | def a2, do: "JM" 9 | def a3, do: "JAM" 10 | 11 | matcher(:regex, ["1658", "1876"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/kn.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.KN do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(869)([2-9].{6})$/ 7 | def country, do: "Saint Kitts and Nevis" 8 | def a2, do: "KN" 9 | def a3, do: "KNA" 10 | 11 | matcher(:regex, ["1869"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/ky.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.KY do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(345)([2-9].{6})$/ 7 | def country, do: "Cayman Islands" 8 | def a2, do: "KY" 9 | def a3, do: "CYM" 10 | 11 | matcher(:regex, ["1345"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/lc.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.LC do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(758)([2-9].{6})$/ 7 | def country, do: "Saint Lucia" 8 | def a2, do: "LC" 9 | def a3, do: "LCA" 10 | 11 | matcher(:regex, ["1758"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/mp.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.MP do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(670)([2-9].{6})$/ 7 | def country, do: "Northern Mariana Islands" 8 | def a2, do: "MP" 9 | def a3, do: "MNP" 10 | 11 | matcher(:regex, ["1670"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/ms.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.MS do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(664)([2-9].{6})$/ 7 | def country, do: "Montserrat" 8 | def a2, do: "MS" 9 | def a3, do: "MSR" 10 | 11 | matcher(:regex, ["1664"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/pr.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.PR do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(787|939)([2-9].{6})$/ 7 | def country, do: "Puerto Rico" 8 | def a2, do: "PR" 9 | def a3, do: "PRI" 10 | 11 | matcher(:regex, ["1787", "1939"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/sx.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.SX do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(721)([2-9].{6})$/ 7 | def country, do: "Sint Maarten" 8 | def a2, do: "SX" 9 | def a3, do: "SXM" 10 | 11 | matcher(:regex, ["1721"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/tc.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.TC do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(649)([2-9].{6})$/ 7 | def country, do: "Turks and Caicos Islands" 8 | def a2, do: "TC" 9 | def a3, do: "TCA" 10 | 11 | matcher(:regex, ["1649"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/toll_free.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.TollFree do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(800|833|844|855|866|877|888)([2-9].{6})$/ 7 | def country, do: "NANP toll-free" 8 | def a2, do: "" 9 | def a3, do: "" 10 | 11 | matcher(:regex, ["1800", "1833", "1844", "1855", "1866", "1877", "1888"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/tt.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.TT do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(868)([2-9].{6})$/ 7 | def country, do: "Trinidad and Tobago" 8 | def a2, do: "TT" 9 | def a3, do: "TTO" 10 | 11 | matcher(:regex, ["1868"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def country, do: "United States" 7 | def a2, do: "US" 8 | def a3, do: "USA" 9 | 10 | matcher(:modules, [ 11 | Phone.NANP.US.AK, 12 | Phone.NANP.US.AL, 13 | Phone.NANP.US.AR, 14 | Phone.NANP.US.AZ, 15 | Phone.NANP.US.CA, 16 | Phone.NANP.US.CO, 17 | Phone.NANP.US.CT, 18 | Phone.NANP.US.DC, 19 | Phone.NANP.US.DE, 20 | Phone.NANP.US.FL, 21 | Phone.NANP.US.GA, 22 | Phone.NANP.US.HI, 23 | Phone.NANP.US.IA, 24 | Phone.NANP.US.ID, 25 | Phone.NANP.US.IL, 26 | Phone.NANP.US.IN, 27 | Phone.NANP.US.KS, 28 | Phone.NANP.US.KY, 29 | Phone.NANP.US.LA, 30 | Phone.NANP.US.MA, 31 | Phone.NANP.US.MD, 32 | Phone.NANP.US.ME, 33 | Phone.NANP.US.MI, 34 | Phone.NANP.US.MN, 35 | Phone.NANP.US.MO, 36 | Phone.NANP.US.MS, 37 | Phone.NANP.US.MT, 38 | Phone.NANP.US.NC, 39 | Phone.NANP.US.ND, 40 | Phone.NANP.US.NE, 41 | Phone.NANP.US.NH, 42 | Phone.NANP.US.NJ, 43 | Phone.NANP.US.NM, 44 | Phone.NANP.US.NV, 45 | Phone.NANP.US.NY, 46 | Phone.NANP.US.OH, 47 | Phone.NANP.US.OK, 48 | Phone.NANP.US.OR, 49 | Phone.NANP.US.PA, 50 | Phone.NANP.US.RI, 51 | Phone.NANP.US.SC, 52 | Phone.NANP.US.SD, 53 | Phone.NANP.US.TN, 54 | Phone.NANP.US.TX, 55 | Phone.NANP.US.UT, 56 | Phone.NANP.US.VT, 57 | Phone.NANP.US.VA, 58 | Phone.NANP.US.WA, 59 | Phone.NANP.US.WI, 60 | Phone.NANP.US.WV, 61 | Phone.NANP.US.WY 62 | ]) 63 | end 64 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/ak.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.AK do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(907)([2-9].{6})$/ 7 | def area_name, do: "Alaska" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "AK" 10 | 11 | matcher(["1907"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/al.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.AL do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(205|251|256|334|659|938)([2-9].{6})$/ 7 | def area_name, do: "Alabama" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "AL" 10 | 11 | matcher(["1205", "1251", "1256", "1334", "1659", "1938"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/ar.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.AR do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(479|501|870)([2-9].{6})$/ 7 | def area_name, do: "Arkansas" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "AR" 10 | 11 | matcher(["1479", "1501", "1870"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/az.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.AZ do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(480|520|602|623|928)([2-9].{6})$/ 7 | def area_name, do: "Arizona" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "AZ" 10 | 11 | matcher(["1480", "1520", "1602", "1623", "1928"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/ca.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.CA do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, 7 | do: 8 | ~r/^(1)(209|279|213|310|323|341|350|408|415|424|442|510|530|559|562|619|626|628|650|657|661|669|707|714|747|760|805|818|820|831|840|858|909|916|925|949|951)([2-9].{6})$/ 9 | 10 | def area_name, do: "California" 11 | def area_type, do: "state" 12 | def area_abbreviation, do: "CA" 13 | 14 | matcher([ 15 | "1209", 16 | "1213", 17 | "1279", 18 | "1310", 19 | "1323", 20 | "1341", 21 | "1350", 22 | "1408", 23 | "1415", 24 | "1424", 25 | "1442", 26 | "1510", 27 | "1530", 28 | "1559", 29 | "1562", 30 | "1619", 31 | "1626", 32 | "1628", 33 | "1650", 34 | "1657", 35 | "1661", 36 | "1669", 37 | "1707", 38 | "1714", 39 | "1747", 40 | "1760", 41 | "1805", 42 | "1818", 43 | "1820", 44 | "1831", 45 | "1840", 46 | "1858", 47 | "1909", 48 | "1916", 49 | "1925", 50 | "1949", 51 | "1951" 52 | ]) 53 | end 54 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/co.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.CO do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(303|719|720|970|983)([2-9].{6})$/ 7 | def area_name, do: "Colorado" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "CO" 10 | 11 | matcher(["1303", "1719", "1720", "1970", "1983"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/ct.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.CT do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(203|475|860|959)([2-9].{6})$/ 7 | def area_name, do: "Connecticut" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "CT" 10 | 11 | matcher(["1203", "1475", "1860", "1959"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/dc.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.DC do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(202|771)([2-9].{6})$/ 7 | def area_name, do: "Washington, D.C." 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "DC" 10 | 11 | matcher(["1202", "1771"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/de.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.DE do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(302)([2-9].{6})$/ 7 | def area_name, do: "Delaware" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "DE" 10 | 11 | matcher(["1302"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/fl.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.FL do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex do 7 | ~r/^(1)(239|305|321|352|386|407|448|561|656|689|727|754|772|786|813|850|863|904|941|954)([2-9].{6})$/ 8 | end 9 | 10 | def area_name, do: "Florida" 11 | def area_type, do: "state" 12 | def area_abbreviation, do: "FL" 13 | 14 | matcher([ 15 | "1239", 16 | "1305", 17 | "1321", 18 | "1352", 19 | "1386", 20 | "1407", 21 | "1448", 22 | "1561", 23 | "1656", 24 | "1689", 25 | "1727", 26 | "1754", 27 | "1772", 28 | "1786", 29 | "1813", 30 | "1850", 31 | "1863", 32 | "1904", 33 | "1941", 34 | "1954" 35 | ]) 36 | end 37 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/ga.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.GA do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(229|404|470|478|678|706|762|770|912|943)([2-9].{6})$/ 7 | def area_name, do: "Georgia" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "GA" 10 | 11 | matcher(["1229", "1404", "1470", "1478", "1678", "1706", "1762", "1770", "1912", "1943"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/hi.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.HI do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(808)([2-9].{6})$/ 7 | def area_name, do: "Hawaii" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "HI" 10 | 11 | matcher(["1808"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/ia.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.IA do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(319|515|563|641|712)([2-9].{6})$/ 7 | def area_name, do: "Iowa" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "IA" 10 | 11 | matcher(["1319", "1515", "1563", "1641", "1712"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/id.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.ID do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(208|986)([2-9].{6})$/ 7 | def area_name, do: "Idaho" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "ID" 10 | 11 | matcher(["1208", "1986"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/il.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.IL do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(217|224|309|312|331|447|464|618|630|708|773|779|815|847|872)([2-9].{6})$/ 7 | def area_name, do: "Illinois" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "IL" 10 | 11 | matcher([ 12 | "1217", 13 | "1224", 14 | "1309", 15 | "1312", 16 | "1331", 17 | "1447", 18 | "1464", 19 | "1618", 20 | "1630", 21 | "1708", 22 | "1773", 23 | "1779", 24 | "1815", 25 | "1847", 26 | "1872" 27 | ]) 28 | end 29 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/in.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.IN do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(219|260|317|463|574|765|812|930)([2-9].{6})$/ 7 | def area_name, do: "Indiana" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "IN" 10 | 11 | matcher(["1219", "1260", "1317", "1463", "1574", "1765", "1812", "1930"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/ks.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.KS do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(316|620|785|913)([2-9].{6})$/ 7 | def area_name, do: "Kansas" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "KS" 10 | 11 | matcher(["1316", "1620", "1785", "1913"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/ky.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.KY do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(270|364|502|606|859)([2-9].{6})$/ 7 | def area_name, do: "Kentucky" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "KY" 10 | 11 | matcher(["1270", "1364", "1502", "1606", "1859"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/la.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.LA do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(225|318|337|504|985)([2-9].{6})$/ 7 | def area_name, do: "Louisiana" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "LA" 10 | 11 | matcher(["1225", "1318", "1337", "1504", "1985"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/ma.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.MA do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(339|351|413|508|617|774|781|857|978)([2-9].{6})$/ 7 | def area_name, do: "Massachusetts" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "MA" 10 | 11 | matcher(["1339", "1351", "1413", "1508", "1617", "1774", "1781", "1857", "1978"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/md.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.MD do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(240|301|410|443|667)([2-9].{6})$/ 7 | def area_name, do: "Maryland" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "MD" 10 | 11 | matcher(["1240", "1301", "1410", "1443", "1667"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/me.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.ME do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(207)([2-9].{6})$/ 7 | def area_name, do: "Maine" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "ME" 10 | 11 | matcher(["1207"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/mi.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.MI do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(231|248|269|313|517|586|616|734|810|906|947|989)([2-9].{6})$/ 7 | def area_name, do: "Michigan" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "MI" 10 | 11 | matcher([ 12 | "1231", 13 | "1248", 14 | "1269", 15 | "1313", 16 | "1517", 17 | "1586", 18 | "1616", 19 | "1734", 20 | "1810", 21 | "1906", 22 | "1947", 23 | "1989" 24 | ]) 25 | end 26 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/mn.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.MN do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(218|320|507|612|651|763|952)([2-9].{6})$/ 7 | def area_name, do: "Minnesota" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "MN" 10 | 11 | matcher(["1218", "1320", "1507", "1612", "1651", "1763", "1952"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/mo.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.MO do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(314|417|557|573|636|660|816)([2-9].{6})$/ 7 | def area_name, do: "Missouri" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "MO" 10 | 11 | matcher(["1314", "1417", "1557", "1573", "1636", "1660", "1816"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/ms.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.MS do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(228|601|662|769)([2-9].{6})$/ 7 | def area_name, do: "Mississippi" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "MS" 10 | 11 | matcher(["1228", "1601", "1662", "1769"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/mt.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.MT do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(406)([2-9].{6})$/ 7 | def area_name, do: "Montana" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "MT" 10 | 11 | matcher(["1406"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/nc.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.NC do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(252|336|472|704|743|828|910|919|980|984)([2-9].{6})$/ 7 | def area_name, do: "North Carolina" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "NC" 10 | 11 | matcher(["1252", "1336", "1472", "1704", "1743", "1828", "1910", "1919", "1980", "1984"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/nd.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.ND do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(701)([2-9].{6})$/ 7 | def area_name, do: "North Dakota" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "ND" 10 | 11 | matcher(["1701"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/ne.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.NE do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(308|402|531)([2-9].{6})$/ 7 | def area_name, do: "Nebraska" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "NE" 10 | 11 | matcher(["1308", "1402", "1531"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/nh.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.NH do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(603)([2-9].{6})$/ 7 | def area_name, do: "New Hampshire" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "NH" 10 | 11 | matcher(["1603"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/nj.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.NJ do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(201|551|609|640|732|848|856|862|908|973)([2-9].{6})$/ 7 | def area_name, do: "New Jersey" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "NJ" 10 | 11 | matcher(["1201", "1551", "1609", "1640", "1732", "1848", "1856", "1862", "1908", "1973"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/nm.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.NM do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(5[0|7]5)([2-9].{6})$/ 7 | def area_name, do: "New Mexico" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "NM" 10 | 11 | matcher(["1505", "1575"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/nv.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.NV do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(702|7[2|7]5)([2-9].{6})$/ 7 | def area_name, do: "Nevada" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "NV" 10 | 11 | matcher(["1702", "1725", "1775"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/ny.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.NY do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, 7 | do: 8 | ~r/^(1)(212|315|332|347|516|518|585|607|631|646|680|716|718|838|845|914|917|929|934)([2-9].{6})$/ 9 | 10 | def area_name, do: "New York" 11 | def area_type, do: "state" 12 | def area_abbreviation, do: "NY" 13 | 14 | matcher([ 15 | "1212", 16 | "1315", 17 | "1332", 18 | "1347", 19 | "1516", 20 | "1518", 21 | "1585", 22 | "1607", 23 | "1631", 24 | "1646", 25 | "1680", 26 | "1716", 27 | "1718", 28 | "1838", 29 | "1845", 30 | "1914", 31 | "1917", 32 | "1929", 33 | "1934" 34 | ]) 35 | end 36 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/oh.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.OH do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(216|220|234|326|330|380|419|440|513|567|614|740|937)([2-9].{6})$/ 7 | def area_name, do: "Ohio" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "OH" 10 | 11 | matcher([ 12 | "1216", 13 | "1220", 14 | "1234", 15 | "1326", 16 | "1330", 17 | "1380", 18 | "1419", 19 | "1440", 20 | "1513", 21 | "1567", 22 | "1614", 23 | "1740", 24 | "1937" 25 | ]) 26 | end 27 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/ok.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.OK do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(405|539|572|580|918)([2-9].{6})$/ 7 | def area_name, do: "Oklahoma" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "OK" 10 | 11 | matcher(["1405", "1539", "1572", "1580", "1918"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/or.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.OR do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(458|503|541|971)([2-9].{6})$/ 7 | def area_name, do: "Oregon" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "OR" 10 | 11 | matcher(["1458", "1503", "1541", "1971"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/pa.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.PA do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(215|223|267|272|412|445|484|570|582|610|717|724|814|835|878)([2-9].{6})$/ 7 | def area_name, do: "Pennsylvania" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "PA" 10 | 11 | matcher([ 12 | "1215", 13 | "1223", 14 | "1267", 15 | "1272", 16 | "1412", 17 | "1445", 18 | "1484", 19 | "1570", 20 | "1582", 21 | "1610", 22 | "1717", 23 | "1724", 24 | "1814", 25 | "1835", 26 | "1878" 27 | ]) 28 | end 29 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/ri.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.RI do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(401)([2-9].{6})$/ 7 | def area_name, do: "Rhode Island" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "RI" 10 | 11 | matcher(["1401"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/sc.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.SC do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(803|839|843|854|864)([2-9].{6})$/ 7 | def area_name, do: "South Carolina" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "SC" 10 | 11 | matcher(["1803", "1839", "1843", "1854", "1864"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/sd.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.SD do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(605)([2-9].{6})$/ 7 | def area_name, do: "South Dakota" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "SD" 10 | 11 | matcher(["1605"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/tn.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.TN do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(423|615|629|731|865|901|931)([2-9].{6})$/ 7 | def area_name, do: "Tennessee" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "TN" 10 | 11 | matcher(["1423", "1615", "1629", "1731", "1865", "1901", "1931"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/tx.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.TX do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, 7 | do: 8 | ~r/^(1)(210|214|254|281|325|346|361|409|430|432|469|512|682|713|726|737|806|817|830|832|903|915|936|940|945|956|972|979)([2-9].{6})$/ 9 | 10 | def area_name, do: "Texas" 11 | def area_type, do: "state" 12 | def area_abbreviation, do: "TX" 13 | 14 | matcher([ 15 | "1210", 16 | "1214", 17 | "1254", 18 | "1281", 19 | "1325", 20 | "1346", 21 | "1361", 22 | "1409", 23 | "1430", 24 | "1432", 25 | "1469", 26 | "1512", 27 | "1682", 28 | "1713", 29 | "1726", 30 | "1737", 31 | "1806", 32 | "1817", 33 | "1830", 34 | "1832", 35 | "1903", 36 | "1915", 37 | "1936", 38 | "1940", 39 | "1945", 40 | "1956", 41 | "1972", 42 | "1979" 43 | ]) 44 | end 45 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/ut.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.UT do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(385|435|801)([2-9].{6})$/ 7 | def area_name, do: "Utah" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "UT" 10 | 11 | matcher(["1385", "1435", "1801"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/va.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.VA do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(276|434|540|571|703|757|804|826|948)([2-9].{6})$/ 7 | def area_name, do: "Virginia" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "VA" 10 | 11 | matcher(["1276", "1434", "1540", "1571", "1703", "1757", "1804", "1826", "1948"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/vt.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.VT do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(802)([2-9].{6})$/ 7 | def area_name, do: "Vermont" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "VT" 10 | 11 | matcher(["1802"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/wa.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.WA do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(206|253|360|425|509|564)([2-9].{6})$/ 7 | def area_name, do: "Washington" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "WA" 10 | 11 | matcher(["1206", "1253", "1360", "1425", "1509", "1564"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/wi.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.WI do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(262|414|534|608|715|920)([2-9].{6})$/ 7 | def area_name, do: "Wisconsin" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "WI" 10 | 11 | matcher(["1262", "1414", "1534", "1608", "1715", "1920"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/wv.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.WV do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(304|681)([2-9].{6})$/ 7 | def area_name, do: "West Virginia" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "WV" 10 | 11 | matcher(["1304", "1681"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/us/wy.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.US.WY do 2 | @moduledoc false 3 | 4 | use Helper.Area 5 | 6 | def regex, do: ~r/^(1)(307)([2-9].{6})$/ 7 | def area_name, do: "Wyoming" 8 | def area_type, do: "state" 9 | def area_abbreviation, do: "WY" 10 | 11 | matcher(["1307"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/vc.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.VC do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(784)([2-9].{6})$/ 7 | def country, do: "Saint Vincent and the Grenadines" 8 | def a2, do: "VC" 9 | def a3, do: "VCT" 10 | 11 | matcher(:regex, ["1784"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/vg.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.VG do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(284)([2-9].{6})$/ 7 | def country, do: "British Virgin Islands" 8 | def a2, do: "VG" 9 | def a3, do: "VGB" 10 | 11 | matcher(:regex, ["1284"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nanp/vi.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANP.VI do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(1)(340)([2-9].{6})$/ 7 | def country, do: "US Virgin Islands" 8 | def a2, do: "VI" 9 | def a3, do: "VIR" 10 | 11 | matcher(:regex, ["1340"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nc.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NC do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(687)()(.{6})/ 7 | def country, do: "New Caledonia" 8 | def a2, do: "NC" 9 | def a3, do: "NCL" 10 | 11 | matcher(:regex, ["687"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ne.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NE do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(227)()(.{8})/ 7 | def country, do: "Niger" 8 | def a2, do: "NE" 9 | def a3, do: "NER" 10 | 11 | matcher(:regex, ["227"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nf.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NF do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(672)(3)([25].{4})/ 7 | def country, do: "Norfolk Island" 8 | def a2, do: "NF" 9 | def a3, do: "NFK" 10 | 11 | matcher(:regex, ["67232", "67235"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ng.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NG do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(234)()(.+)/ 7 | def country, do: "Nigeria" 8 | def a2, do: "NG" 9 | def a3, do: "NGA" 10 | 11 | matcher(:regex, ["234"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ni.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NI do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(505)()(.{8})/ 7 | def country, do: "Nicaragua" 8 | def a2, do: "NI" 9 | def a3, do: "NIC" 10 | 11 | matcher(:regex, ["505"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nl.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NL do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(31)()(.{9,10})/ 7 | def country, do: "Netherlands" 8 | def a2, do: "NL" 9 | def a3, do: "NLD" 10 | 11 | matcher(:regex, ["31"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/no.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NO do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(47)()([2-9].{7}|0.{3})/ 7 | def country, do: "Norway" 8 | def a2, do: "NO" 9 | def a3, do: "NOR" 10 | 11 | matcher(:regex, ["47"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/np.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NP do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(977)()(.{8})/ 7 | def country, do: "Nepal" 8 | def a2, do: "NP" 9 | def a3, do: "NPL" 10 | 11 | matcher(:regex, ["977"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nr.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NR do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(674)()(.{7})/ 7 | def country, do: "Nauru" 8 | def a2, do: "NR" 9 | def a3, do: "NRU" 10 | 11 | matcher(:regex, ["674"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nu.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NU do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(683)()(.{4})/ 7 | def country, do: "Niue" 8 | def a2, do: "NU" 9 | def a3, do: "NIU" 10 | 11 | matcher(:regex, ["683"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/nz.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.NZ do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(64)()(.+)/ 7 | def country, do: "New Zealand" 8 | def a2, do: "NZ" 9 | def a3, do: "NZL" 10 | 11 | matcher(:regex, ["64"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/om.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.OM do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(968)()(.{8})/ 7 | def country, do: "Oman" 8 | def a2, do: "OM" 9 | def a3, do: "OMN" 10 | 11 | matcher(:regex, ["968"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/pa.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.PA do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(507)()(.{7})/ 7 | def country, do: "Panama" 8 | def a2, do: "PA" 9 | def a3, do: "PAN" 10 | 11 | matcher(:regex, ["507"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/pe.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.PE do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(51)()(.{8,9})/ 7 | def country, do: "Peru" 8 | def a2, do: "PE" 9 | def a3, do: "PER" 10 | 11 | matcher(:regex, ["51"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/pf.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.PF do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(689)()(.{8})/ 7 | def country, do: "French Polynesia" 8 | def a2, do: "PF" 9 | def a3, do: "PYF" 10 | 11 | matcher(:regex, ["689"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/pg.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.PG do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(675)()(.+)/ 7 | def country, do: "Papua New Guinea" 8 | def a2, do: "PG" 9 | def a3, do: "PNG" 10 | 11 | matcher(:regex, ["675"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ph.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.PH do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(63)()(.+)/ 7 | def country, do: "Philippines" 8 | def a2, do: "PH" 9 | def a3, do: "PHL" 10 | 11 | matcher(:regex, ["63"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/pk.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.PK do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(92)()(.+)/ 7 | def country, do: "Pakistan" 8 | def a2, do: "PK" 9 | def a3, do: "PAK" 10 | 11 | matcher(:regex, ["92"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/pl.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.PL do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(48)()(.+)/ 7 | def country, do: "Poland" 8 | def a2, do: "PL" 9 | def a3, do: "POL" 10 | 11 | matcher(:regex, ["48"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/pm.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.PM do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(508)()(.{6})/ 7 | def country, do: "Saint Pierre and Miquelon" 8 | def a2, do: "PM" 9 | def a3, do: "SPM" 10 | 11 | matcher(:regex, ["508"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ps.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.PS do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(970)()(.{8,9})/ 7 | def country, do: "Palestine" 8 | def a2, do: "DJ" 9 | def a3, do: "DJI" 10 | 11 | matcher(:regex, ["970"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/pt.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.PT do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(351)()(.{9})/ 7 | def country, do: "Portugal" 8 | def a2, do: "PT" 9 | def a3, do: "PRT" 10 | 11 | matcher(:regex, ["351"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/pw.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.PW do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(680)()(.{7})/ 7 | def country, do: "Palau" 8 | def a2, do: "PW" 9 | def a3, do: "PLW" 10 | 11 | matcher(:regex, ["680"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/py.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.PY do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(595)()(.+)/ 7 | def country, do: "Paraguay" 8 | def a2, do: "PY" 9 | def a3, do: "PRY" 10 | 11 | matcher(:regex, ["595"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/qa.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.QA do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(974)()(.{8})/ 7 | def country, do: "Qatar" 8 | def a2, do: "QA" 9 | def a3, do: "QAT" 10 | 11 | matcher(:regex, ["974"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/re.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.RE do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(262)(.{3})(.{6})/ 7 | def country, do: "Réunion" 8 | def a2, do: "RE" 9 | def a3, do: "REU" 10 | 11 | matcher(:regex, ["262"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ro.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.RO do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(40)()(.{9})/ 7 | def country, do: "Romania" 8 | def a2, do: "RO" 9 | def a3, do: "ROU" 10 | 11 | matcher(:regex, ["40"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/rs.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.RS do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(381)()(.+)/ 7 | def country, do: "Serbia" 8 | def a2, do: "RS" 9 | def a3, do: "SRB" 10 | 11 | matcher(:regex, ["381"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ru.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.RU do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(7)([3-589]..)(.{7})/ 7 | def country, do: "Russia" 8 | def a2, do: "RU" 9 | def a3, do: "RUS" 10 | 11 | matcher(:regex, ["73", "74", "75", "78", "79"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/rw.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.RW do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(250)()(.{9})/ 7 | def country, do: "Rwanda" 8 | def a2, do: "RW" 9 | def a3, do: "RWA" 10 | 11 | matcher(:regex, ["250"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/sa.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.SA do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(966)()(.+)/ 7 | def country, do: "Saudi Arabia" 8 | def a2, do: "SA" 9 | def a3, do: "SAU" 10 | 11 | matcher(:regex, ["966"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/sb.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.SB do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(677)()(.+)/ 7 | def country, do: "Solomon Islands" 8 | def a2, do: "SB" 9 | def a3, do: "SLB" 10 | 11 | matcher(:regex, ["677"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/sc.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.SC do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(248)()(.{7})/ 7 | def country, do: "Seychelles" 8 | def a2, do: "SC" 9 | def a3, do: "SYC" 10 | 11 | matcher(:regex, ["248:"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/sd.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.SD do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(249)()(.+)/ 7 | def country, do: "Sudan" 8 | def a2, do: "SD" 9 | def a3, do: "SDN" 10 | 11 | matcher(:regex, ["249"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/se.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.SE do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(46)()(.+)/ 7 | def country, do: "Sweden" 8 | def a2, do: "SE" 9 | def a3, do: "SWE" 10 | 11 | matcher(:regex, ["46"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/sg.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.SG do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | def regex, do: ~r/^(65)()(.{10}|.{8})/ 6 | def country, do: "Singapore" 7 | def a2, do: "SG" 8 | def a3, do: "SGP" 9 | 10 | matcher(:regex, ["65"]) 11 | end 12 | -------------------------------------------------------------------------------- /lib/phone/sh.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.SH do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(290)()(.{5})/ 7 | def country, do: "Saint Helena and Tristan da Cunha" 8 | def a2, do: "SH" 9 | def a3, do: "SHN" 10 | 11 | matcher(:regex, ["290"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/si.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.SI do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(386)()(.+)/ 7 | def country, do: "Slovenia" 8 | def a2, do: "SI" 9 | def a3, do: "SVN" 10 | 11 | matcher(:regex, ["386"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/sk.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.SK do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(421)()(.+)/ 7 | def country, do: "Slovakia" 8 | def a2, do: "SK" 9 | def a3, do: "SVK" 10 | 11 | matcher(:regex, ["421"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/sl.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.SL do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(232)(..)(.{6})/ 7 | def country, do: "Sierra Leone" 8 | def a2, do: "SL" 9 | def a3, do: "SLE" 10 | 11 | matcher(:regex, ["232"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/sm.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.SM do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(378)(0549)(.{6})/ 7 | def country, do: "San Marino" 8 | def a2, do: "SM" 9 | def a3, do: "SMR" 10 | 11 | matcher(:regex, ["3780549"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/sn.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.SN do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(221)()(.{7})/ 7 | def country, do: "Senegal" 8 | def a2, do: "SN" 9 | def a3, do: "SEN" 10 | 11 | matcher(:regex, ["221"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/so.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.SO do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(252)()(.+)/ 7 | def country, do: "Somalia" 8 | def a2, do: "SO" 9 | def a3, do: "SOM" 10 | 11 | matcher(:regex, ["252"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/sr.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.SR do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(597)()(.{6,7})/ 7 | def country, do: "Suriname" 8 | def a2, do: "SR" 9 | def a3, do: "SUR" 10 | 11 | matcher(:regex, ["597"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ss.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.SS do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(211)()(.+)/ 7 | def country, do: "South Sudan" 8 | def a2, do: "SS" 9 | def a3, do: "SSD" 10 | 11 | matcher(:regex, ["211"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/st.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ST do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(239)()(.{7})/ 7 | def country, do: "Sao Tome and Principe" 8 | def a2, do: "ST" 9 | def a3, do: "STP" 10 | 11 | matcher(:regex, ["239"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/sv.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.SV do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(503)()(.{7,8})/ 7 | def country, do: "El Salvador" 8 | def a2, do: "SV" 9 | def a3, do: "SLV" 10 | 11 | matcher(:regex, ["503"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/sy.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.SY do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(963)()(.+)/ 7 | def country, do: "Syria" 8 | def a2, do: "SY" 9 | def a3, do: "SYR" 10 | 11 | matcher(:regex, ["963"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/sz.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.SZ do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(268)()(.{8})/ 7 | def country, do: "Swaziland" 8 | def a2, do: "SZ" 9 | def a3, do: "SWZ" 10 | 11 | matcher(:regex, ["268"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/td.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.TD do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(235)()(.{8})/ 7 | def country, do: "Chad" 8 | def a2, do: "TD" 9 | def a3, do: "TCD" 10 | 11 | matcher(:regex, ["235"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/tg.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.TG do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(228)()(.{8})/ 7 | def country, do: "Togo" 8 | def a2, do: "TG" 9 | def a3, do: "TGO" 10 | 11 | matcher(:regex, ["228"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/th.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.TH do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(66)()(.+)/ 7 | def country, do: "Thailand" 8 | def a2, do: "TH" 9 | def a3, do: "THA" 10 | 11 | matcher(:regex, ["66"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/tj.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.TJ do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(992)()(.{9})/ 7 | def country, do: "Tajikistan" 8 | def a2, do: "TJ" 9 | def a3, do: "TJK" 10 | 11 | matcher(:regex, ["992"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/tk.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.TK do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(690)([1-9])(.{3})/ 7 | def country, do: "Tokelau" 8 | def a2, do: "TK" 9 | def a3, do: "TKL" 10 | 11 | matcher(:regex, ["690"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/tl.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.TL do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(670)()(.{8})/ 7 | def country, do: "East Timor" 8 | def a2, do: "TL" 9 | def a3, do: "TLS" 10 | 11 | matcher(:regex, ["670"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/tm.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.TM do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(993)()(.+)/ 7 | def country, do: "Turkmenistan" 8 | def a2, do: "TM" 9 | def a3, do: "TKM" 10 | 11 | matcher(:regex, ["993"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/tn.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.TN do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(216)()(.{8})/ 7 | def country, do: "Tunisia" 8 | def a2, do: "TN" 9 | def a3, do: "TUN" 10 | 11 | matcher(:regex, ["216"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/to.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.TO do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(676)()(.+)/ 7 | def country, do: "Tonga" 8 | def a2, do: "TO" 9 | def a3, do: "TON" 10 | 11 | matcher(:regex, ["676"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/tr.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.TR do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(90)(.{3})(.{7})/ 7 | def country, do: "Turkey" 8 | def a2, do: "TR" 9 | def a3, do: "TUR" 10 | 11 | matcher(:regex, ["90"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/tv.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.TV do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(688)()(.{5,6})/ 7 | def country, do: "Tuvalu" 8 | def a2, do: "TV" 9 | def a3, do: "TUV" 10 | 11 | matcher(:regex, ["688"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/tw.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.TW do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(886)()(.+)/ 7 | def country, do: "Taiwan" 8 | def a2, do: "TW" 9 | def a3, do: "TWN" 10 | 11 | matcher(:regex, ["886"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/tz.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.TZ do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(255)()(.{9})/ 7 | def country, do: "Tanzania" 8 | def a2, do: "TZ" 9 | def a3, do: "TZA" 10 | 11 | matcher(:regex, ["255"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ua.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.UA do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(380)()(.{9})/ 7 | def country, do: "Ukraine" 8 | def a2, do: "UA" 9 | def a3, do: "UKR" 10 | 11 | matcher(:regex, ["380"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ug.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.UG do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(256)()(.{8})/ 7 | def country, do: "Uganda" 8 | def a2, do: "UG" 9 | def a3, do: "UGA" 10 | 11 | matcher(:regex, ["256"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/uy.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.UY do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(598)()(.+)/ 7 | def country, do: "Uruguay" 8 | def a2, do: "UY" 9 | def a3, do: "URY" 10 | 11 | matcher(:regex, ["598"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/uz.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.UZ do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(998)()(.{9})/ 7 | def country, do: "Uzbekistan" 8 | def a2, do: "UZ" 9 | def a3, do: "UZB" 10 | 11 | matcher(:regex, ["998"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ve.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.VE do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(58)(.{3})(.{7})/ 7 | def country, do: "Venezuela" 8 | def a2, do: "VE" 9 | def a3, do: "VEN" 10 | 11 | matcher(:regex, ["58"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/vn.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.VN do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(84)()(.+)/ 7 | def country, do: "Vietnam" 8 | def a2, do: "VN" 9 | def a3, do: "VNM" 10 | 11 | matcher(:regex, ["84"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/vu.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.VU do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(678)()(.{5})/ 7 | def country, do: "Vanuatu" 8 | def a2, do: "VU" 9 | def a3, do: "VUT" 10 | 11 | matcher(:regex, ["678"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/wf.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.WF do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(681)()(.{6})/ 7 | def country, do: "Wallis and Futuna" 8 | def a2, do: "WF" 9 | def a3, do: "WLF" 10 | 11 | matcher(:regex, ["681"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ws.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.WS do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(685)()(.{6,7})/ 7 | def country, do: "Samoa" 8 | def a2, do: "WS" 9 | def a3, do: "WSM" 10 | 11 | matcher(:regex, ["685"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/ye.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.YE do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(967)()(.+)/ 7 | def country, do: "Yemen" 8 | def a2, do: "YE" 9 | def a3, do: "YEM" 10 | 11 | matcher(:regex, ["967"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/za.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ZA do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(27)()(.{9})/ 7 | def country, do: "South Africa" 8 | def a2, do: "ZA" 9 | def a3, do: "ZAF" 10 | 11 | matcher(:regex, ["27"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/zm.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ZM do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(260)()(.{7})/ 7 | def country, do: "Zambia" 8 | def a2, do: "ZM" 9 | def a3, do: "ZMB" 10 | 11 | matcher(:regex, ["260"]) 12 | end 13 | -------------------------------------------------------------------------------- /lib/phone/zw.ex: -------------------------------------------------------------------------------- 1 | defmodule Phone.ZW do 2 | @moduledoc false 3 | 4 | use Helper.Country 5 | 6 | def regex, do: ~r/^(263)()(.+)/ 7 | def country, do: "Zimbabwe" 8 | def a2, do: "ZW" 9 | def a3, do: "ZWE" 10 | 11 | matcher(:regex, ["263"]) 12 | end 13 | -------------------------------------------------------------------------------- /mix.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.Mixfile do 2 | use Mix.Project 3 | 4 | @source_url "https://github.com/fcevado/phone" 5 | @version "0.5.11" 6 | 7 | def project do 8 | [ 9 | app: :phone, 10 | version: @version, 11 | elixir: ">= 1.1.0", 12 | build_embedded: Mix.env() == :prod, 13 | start_permanent: Mix.env() == :prod, 14 | package: package(), 15 | deps: deps(), 16 | docs: docs() 17 | ] ++ coverage() 18 | end 19 | 20 | def application do 21 | [extra_applications: []] 22 | end 23 | 24 | defp package do 25 | [ 26 | description: """ 27 | Phone number parser for telephone numbers in international standard or 28 | missing international country code. 29 | """, 30 | maintainers: ["Flávio M.V."], 31 | licenses: ["Apache-2.0"], 32 | links: %{ 33 | "Changelog" => "https://hexdocs.pm/phone/changelog.html", 34 | "GitHub" => @source_url 35 | } 36 | ] 37 | end 38 | 39 | defp deps do 40 | [ 41 | {:excoveralls, "~> 0.18", only: :test, runtime: false}, 42 | {:credo, "~> 1.7", only: :dev, runtime: false}, 43 | {:ex_doc, "~> 0.38", only: :dev, runtime: false}, 44 | {:benchfella, "0.3.5", only: :dev} 45 | ] 46 | end 47 | 48 | defp docs do 49 | [ 50 | extras: ["CHANGELOG.md", "README.md"], 51 | main: "readme", 52 | formatters: ["html"], 53 | api_reference: false, 54 | skip_undefined_reference_warnings_on: ["CHANGELOG.md"] 55 | ] 56 | end 57 | 58 | defp coverage do 59 | [ 60 | test_coverage: [tool: ExCoveralls], 61 | preferred_cli_env: [ 62 | coveralls: :test, 63 | "coveralls.detail": :test, 64 | "coveralls.post": :test, 65 | "coveralls.html": :test 66 | ] 67 | ] 68 | end 69 | end 70 | -------------------------------------------------------------------------------- /test/phone/a_countries/ad_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.ADTest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.AD 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}555555")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}555555")) 10 | 11 | assert parsed.country == unquote(main_module).country 12 | assert parsed.a2 == unquote(main_module).a2 13 | assert parsed.a3 == unquote(main_module).a3 14 | end 15 | 16 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 17 | refute Phone.valid?(unquote("#{code}555")) 18 | assert {:error, _} = Phone.parse(unquote("#{code}555")) 19 | 20 | refute unquote(main_module).match?(unquote("#{code}555")) 21 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555")) 22 | 23 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 24 | unquote(main_module).build!(unquote("#{code}555")) 25 | end 26 | end 27 | end) 28 | end 29 | -------------------------------------------------------------------------------- /test/phone/a_countries/ae_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.AETest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.AE 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}55555555")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}55555555")) 10 | 11 | assert parsed.country == unquote(main_module).country 12 | assert parsed.a2 == unquote(main_module).a2 13 | assert parsed.a3 == unquote(main_module).a3 14 | end 15 | 16 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 17 | refute Phone.valid?(unquote("#{code}555")) 18 | assert {:error, _} = Phone.parse(unquote("#{code}555")) 19 | 20 | refute unquote(main_module).match?(unquote("#{code}555")) 21 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555")) 22 | 23 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 24 | unquote(main_module).build!(unquote("#{code}555")) 25 | end 26 | end 27 | end) 28 | end 29 | -------------------------------------------------------------------------------- /test/phone/a_countries/af_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.AFTest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.AE 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}555555555")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}555555555")) 10 | 11 | assert parsed.country == unquote(main_module).country 12 | assert parsed.a2 == unquote(main_module).a2 13 | assert parsed.a3 == unquote(main_module).a3 14 | end 15 | 16 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 17 | refute Phone.valid?(unquote("#{code}555")) 18 | assert {:error, _} = Phone.parse(unquote("#{code}555")) 19 | 20 | refute unquote(main_module).match?(unquote("#{code}555")) 21 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555")) 22 | 23 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 24 | unquote(main_module).build!(unquote("#{code}555")) 25 | end 26 | end 27 | end) 28 | end 29 | -------------------------------------------------------------------------------- /test/phone/a_countries/al_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.ALTest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.AL 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}5555555")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}5555555")) 10 | 11 | assert parsed.country == unquote(main_module).country 12 | assert parsed.a2 == unquote(main_module).a2 13 | assert parsed.a3 == unquote(main_module).a3 14 | end 15 | 16 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 17 | refute Phone.valid?(unquote("#{code}555")) 18 | assert {:error, _} = Phone.parse(unquote("#{code}555")) 19 | 20 | refute unquote(main_module).match?(unquote("#{code}555")) 21 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555")) 22 | 23 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 24 | unquote(main_module).build!(unquote("#{code}555")) 25 | end 26 | end 27 | end) 28 | end 29 | -------------------------------------------------------------------------------- /test/phone/a_countries/am_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.AMTest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.AM 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}55555555")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}55555555")) 10 | 11 | assert parsed.country == unquote(main_module).country 12 | assert parsed.a2 == unquote(main_module).a2 13 | assert parsed.a3 == unquote(main_module).a3 14 | end 15 | 16 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 17 | refute Phone.valid?(unquote("#{code}555")) 18 | assert {:error, _} = Phone.parse(unquote("#{code}555")) 19 | 20 | refute unquote(main_module).match?(unquote("#{code}555")) 21 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555")) 22 | 23 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 24 | unquote(main_module).build!(unquote("#{code}555")) 25 | end 26 | end 27 | end) 28 | end 29 | -------------------------------------------------------------------------------- /test/phone/a_countries/ao_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.AOTest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.AO 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}555555555")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}555555555")) 10 | 11 | assert parsed.country == unquote(main_module).country 12 | assert parsed.a2 == unquote(main_module).a2 13 | assert parsed.a3 == unquote(main_module).a3 14 | end 15 | 16 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 17 | refute Phone.valid?(unquote("#{code}555")) 18 | assert {:error, _} = Phone.parse(unquote("#{code}555")) 19 | 20 | refute unquote(main_module).match?(unquote("#{code}555")) 21 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555")) 22 | 23 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 24 | unquote(main_module).build!(unquote("#{code}555")) 25 | end 26 | end 27 | end) 28 | end 29 | -------------------------------------------------------------------------------- /test/phone/a_countries/ar_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.ARTest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.AR 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}5555555555")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}5555555555")) 10 | 11 | assert parsed.country == unquote(main_module).country 12 | assert parsed.a2 == unquote(main_module).a2 13 | assert parsed.a3 == unquote(main_module).a3 14 | end 15 | 16 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 17 | refute Phone.valid?(unquote("#{code}555")) 18 | assert {:error, _} = Phone.parse(unquote("#{code}555")) 19 | 20 | refute unquote(main_module).match?(unquote("#{code}555")) 21 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555")) 22 | 23 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 24 | unquote(main_module).build!(unquote("#{code}555")) 25 | end 26 | end 27 | end) 28 | end 29 | -------------------------------------------------------------------------------- /test/phone/a_countries/at_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.ATTest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.AT 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}99")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}99")) 10 | 11 | assert parsed.country == unquote(main_module).country 12 | assert parsed.a2 == unquote(main_module).a2 13 | assert parsed.a3 == unquote(main_module).a3 14 | end 15 | 16 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 17 | refute Phone.valid?(unquote("#{code}")) 18 | assert {:error, _} = Phone.parse(unquote("#{code}")) 19 | 20 | refute unquote(main_module).match?(unquote("#{code}")) 21 | assert {:error, _} = unquote(main_module).build(unquote("#{code}")) 22 | 23 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 24 | unquote(main_module).build!(unquote("#{code}")) 25 | end 26 | end 27 | end) 28 | end 29 | -------------------------------------------------------------------------------- /test/phone/a_countries/au_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.AUTest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.AU 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}55555555")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}55555555")) 10 | 11 | assert parsed.country == unquote(main_module).country 12 | assert parsed.a2 == unquote(main_module).a2 13 | assert parsed.a3 == unquote(main_module).a3 14 | end 15 | 16 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 17 | refute Phone.valid?(unquote("#{code}555")) 18 | assert {:error, _} = Phone.parse(unquote("#{code}555")) 19 | 20 | refute unquote(main_module).match?(unquote("#{code}555")) 21 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555")) 22 | 23 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 24 | unquote(main_module).build!(unquote("#{code}555")) 25 | end 26 | end 27 | end) 28 | end 29 | -------------------------------------------------------------------------------- /test/phone/a_countries/aw_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.AWTest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.AW 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}5555555")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}5555555")) 10 | 11 | assert parsed.country == unquote(main_module).country 12 | assert parsed.a2 == unquote(main_module).a2 13 | assert parsed.a3 == unquote(main_module).a3 14 | end 15 | 16 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 17 | refute Phone.valid?(unquote("#{code}555")) 18 | assert {:error, _} = Phone.parse(unquote("#{code}555")) 19 | 20 | refute unquote(main_module).match?(unquote("#{code}555")) 21 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555")) 22 | 23 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 24 | unquote(main_module).build!(unquote("#{code}555")) 25 | end 26 | end 27 | end) 28 | end 29 | -------------------------------------------------------------------------------- /test/phone/a_countries/az_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.AZTest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.AZ 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}555555555")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}555555555")) 10 | 11 | assert parsed.country == unquote(main_module).country 12 | assert parsed.a2 == unquote(main_module).a2 13 | assert parsed.a3 == unquote(main_module).a3 14 | end 15 | 16 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 17 | refute Phone.valid?(unquote("#{code}555")) 18 | assert {:error, _} = Phone.parse(unquote("#{code}555")) 19 | 20 | refute unquote(main_module).match?(unquote("#{code}555")) 21 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555")) 22 | 23 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 24 | unquote(main_module).build!(unquote("#{code}555")) 25 | end 26 | end 27 | end) 28 | end 29 | -------------------------------------------------------------------------------- /test/phone/b_countries/ba_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.BATest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.BA 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}55555555")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}55555555")) 10 | 11 | assert parsed.country == unquote(main_module).country 12 | assert parsed.a2 == unquote(main_module).a2 13 | assert parsed.a3 == unquote(main_module).a3 14 | end 15 | 16 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 17 | refute Phone.valid?(unquote("#{code}555")) 18 | assert {:error, _} = Phone.parse(unquote("#{code}555")) 19 | 20 | refute unquote(main_module).match?(unquote("#{code}555")) 21 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555")) 22 | 23 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 24 | unquote(main_module).build!(unquote("#{code}555")) 25 | end 26 | end 27 | end) 28 | end 29 | -------------------------------------------------------------------------------- /test/phone/b_countries/bd_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.BDTest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.BD 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}5555555555")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}5555555555")) 10 | 11 | assert parsed.country == unquote(main_module).country 12 | assert parsed.a2 == unquote(main_module).a2 13 | assert parsed.a3 == unquote(main_module).a3 14 | end 15 | 16 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 17 | refute Phone.valid?(unquote("#{code}555")) 18 | assert {:error, _} = Phone.parse(unquote("#{code}555")) 19 | 20 | refute unquote(main_module).match?(unquote("#{code}555")) 21 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555")) 22 | 23 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 24 | unquote(main_module).build!(unquote("#{code}555")) 25 | end 26 | end 27 | end) 28 | end 29 | -------------------------------------------------------------------------------- /test/phone/b_countries/be_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.BETest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.BE 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}555555555")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}555555555")) 10 | 11 | assert parsed.country == unquote(main_module).country 12 | assert parsed.a2 == unquote(main_module).a2 13 | assert parsed.a3 == unquote(main_module).a3 14 | end 15 | 16 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 17 | refute Phone.valid?(unquote("#{code}555")) 18 | assert {:error, _} = Phone.parse(unquote("#{code}555")) 19 | 20 | refute unquote(main_module).match?(unquote("#{code}555")) 21 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555")) 22 | 23 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 24 | unquote(main_module).build!(unquote("#{code}555")) 25 | end 26 | end 27 | end) 28 | end 29 | -------------------------------------------------------------------------------- /test/phone/b_countries/bg_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.BGTest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.BG 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}555555555")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}555555555")) 10 | 11 | assert parsed.country == unquote(main_module).country 12 | assert parsed.a2 == unquote(main_module).a2 13 | assert parsed.a3 == unquote(main_module).a3 14 | end 15 | 16 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 17 | refute Phone.valid?(unquote("#{code}555")) 18 | assert {:error, _} = Phone.parse(unquote("#{code}555")) 19 | 20 | refute unquote(main_module).match?(unquote("#{code}555")) 21 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555")) 22 | 23 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 24 | unquote(main_module).build!(unquote("#{code}555")) 25 | end 26 | end 27 | end) 28 | end 29 | -------------------------------------------------------------------------------- /test/phone/b_countries/bh_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.BHTest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.BH 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}55555555")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}55555555")) 10 | 11 | assert parsed.country == unquote(main_module).country 12 | assert parsed.a2 == unquote(main_module).a2 13 | assert parsed.a3 == unquote(main_module).a3 14 | end 15 | 16 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 17 | refute Phone.valid?(unquote("#{code}555")) 18 | assert {:error, _} = Phone.parse(unquote("#{code}555")) 19 | 20 | refute unquote(main_module).match?(unquote("#{code}555")) 21 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555")) 22 | 23 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 24 | unquote(main_module).build!(unquote("#{code}555")) 25 | end 26 | end 27 | end) 28 | end 29 | -------------------------------------------------------------------------------- /test/phone/b_countries/bi_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.BITest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.BI 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}55555555")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}55555555")) 10 | 11 | assert parsed.country == unquote(main_module).country 12 | assert parsed.a2 == unquote(main_module).a2 13 | assert parsed.a3 == unquote(main_module).a3 14 | end 15 | 16 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 17 | refute Phone.valid?(unquote("#{code}555")) 18 | assert {:error, _} = Phone.parse(unquote("#{code}555")) 19 | 20 | refute unquote(main_module).match?(unquote("#{code}555")) 21 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555")) 22 | 23 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 24 | unquote(main_module).build!(unquote("#{code}555")) 25 | end 26 | end 27 | end) 28 | end 29 | -------------------------------------------------------------------------------- /test/phone/b_countries/bj_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.BJTest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.BJ 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}55555555")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}55555555")) 10 | 11 | assert parsed.country == unquote(main_module).country 12 | assert parsed.a2 == unquote(main_module).a2 13 | assert parsed.a3 == unquote(main_module).a3 14 | end 15 | 16 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 17 | refute Phone.valid?(unquote("#{code}555")) 18 | assert {:error, _} = Phone.parse(unquote("#{code}555")) 19 | 20 | refute unquote(main_module).match?(unquote("#{code}555")) 21 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555")) 22 | 23 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 24 | unquote(main_module).build!(unquote("#{code}555")) 25 | end 26 | end 27 | end) 28 | end 29 | -------------------------------------------------------------------------------- /test/phone/b_countries/bn_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.BNTest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.BN 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}5555555")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}5555555")) 10 | 11 | assert parsed.country == unquote(main_module).country 12 | assert parsed.a2 == unquote(main_module).a2 13 | assert parsed.a3 == unquote(main_module).a3 14 | end 15 | 16 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 17 | refute Phone.valid?(unquote("#{code}555")) 18 | assert {:error, _} = Phone.parse(unquote("#{code}555")) 19 | 20 | refute unquote(main_module).match?(unquote("#{code}555")) 21 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555")) 22 | 23 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 24 | unquote(main_module).build!(unquote("#{code}555")) 25 | end 26 | end 27 | end) 28 | end 29 | -------------------------------------------------------------------------------- /test/phone/b_countries/bo_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.BOTest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.BO 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}55555555")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}55555555")) 10 | 11 | assert parsed.country == unquote(main_module).country 12 | assert parsed.a2 == unquote(main_module).a2 13 | assert parsed.a3 == unquote(main_module).a3 14 | end 15 | 16 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 17 | refute Phone.valid?(unquote("#{code}555")) 18 | assert {:error, _} = Phone.parse(unquote("#{code}555")) 19 | 20 | refute unquote(main_module).match?(unquote("#{code}555")) 21 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555")) 22 | 23 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 24 | unquote(main_module).build!(unquote("#{code}555")) 25 | end 26 | end 27 | end) 28 | end 29 | -------------------------------------------------------------------------------- /test/phone/b_countries/bt_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.BTTest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.BT 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}55555555")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}55555555")) 10 | 11 | assert parsed.country == unquote(main_module).country 12 | assert parsed.a2 == unquote(main_module).a2 13 | assert parsed.a3 == unquote(main_module).a3 14 | end 15 | 16 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 17 | refute Phone.valid?(unquote("#{code}555")) 18 | assert {:error, _} = Phone.parse(unquote("#{code}555")) 19 | 20 | refute unquote(main_module).match?(unquote("#{code}555")) 21 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555")) 22 | 23 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 24 | unquote(main_module).build!(unquote("#{code}555")) 25 | end 26 | end 27 | end) 28 | end 29 | -------------------------------------------------------------------------------- /test/phone/b_countries/bw_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.BWTest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.BW 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}5555555")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}5555555")) 10 | 11 | assert parsed.country == unquote(main_module).country 12 | assert parsed.a2 == unquote(main_module).a2 13 | assert parsed.a3 == unquote(main_module).a3 14 | end 15 | 16 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 17 | refute Phone.valid?(unquote("#{code}555")) 18 | assert {:error, _} = Phone.parse(unquote("#{code}555")) 19 | 20 | refute unquote(main_module).match?(unquote("#{code}555")) 21 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555")) 22 | 23 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 24 | unquote(main_module).build!(unquote("#{code}555")) 25 | end 26 | end 27 | end) 28 | end 29 | -------------------------------------------------------------------------------- /test/phone/b_countries/by_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.BYTest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.BY 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}555555555")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}555555555")) 10 | 11 | assert parsed.country == unquote(main_module).country 12 | assert parsed.a2 == unquote(main_module).a2 13 | assert parsed.a3 == unquote(main_module).a3 14 | end 15 | 16 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 17 | refute Phone.valid?(unquote("#{code}555")) 18 | assert {:error, _} = Phone.parse(unquote("#{code}555")) 19 | 20 | refute unquote(main_module).match?(unquote("#{code}555")) 21 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555")) 22 | 23 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 24 | unquote(main_module).build!(unquote("#{code}555")) 25 | end 26 | end 27 | end) 28 | end 29 | -------------------------------------------------------------------------------- /test/phone/b_countries/bz_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.BZTest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.BZ 5 | 6 | Enum.map(main_module.codes, fn code -> 7 | test "#{inspect(main_module)} parses area code #{code}" do 8 | assert Phone.valid?(unquote("#{code}5555555")) 9 | assert {:ok, parsed} = Phone.parse(unquote("#{code}5555555")) 10 | 11 | assert unquote(main_module).match?(unquote("#{code}5555555")) 12 | assert {:ok, parsed2} = unquote(main_module).build(unquote("#{code}5555555")) 13 | 14 | assert parsed.country == unquote(main_module).country 15 | assert parsed.a2 == unquote(main_module).a2 16 | assert parsed.a3 == unquote(main_module).a3 17 | assert parsed == parsed2 18 | end 19 | 20 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 21 | refute Phone.valid?(unquote("#{code}555")) 22 | assert {:error, _} = Phone.parse(unquote("#{code}555")) 23 | 24 | refute unquote(main_module).match?(unquote("#{code}555")) 25 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555")) 26 | 27 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 28 | unquote(main_module).build!(unquote("#{code}555")) 29 | end 30 | 31 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 32 | Phone.parse!(unquote("#{code}555")) 33 | end 34 | end 35 | end) 36 | end 37 | -------------------------------------------------------------------------------- /test/phone/c_countries/ca_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.CATest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.NANP.CA 5 | 6 | all_modules = [ 7 | Phone.NANP.CA.AB, 8 | Phone.NANP.CA.BC, 9 | Phone.NANP.CA.MB, 10 | Phone.NANP.CA.NB, 11 | Phone.NANP.CA.NL, 12 | Phone.NANP.CA.NSAndPE, 13 | Phone.NANP.CA.ON, 14 | Phone.NANP.CA.QC, 15 | Phone.NANP.CA.SK, 16 | Phone.NANP.CA.Territory 17 | ] 18 | 19 | Enum.map(main_module.codes, fn code -> 20 | test "#{inspect(main_module)} parses area code #{code}" do 21 | assert Phone.valid?(unquote("#{code}5551234")) 22 | assert {:ok, parsed} = Phone.parse(unquote("#{code}5551234")) 23 | 24 | assert parsed.country == unquote(main_module).country 25 | assert parsed.a2 == unquote(main_module).a2 26 | assert parsed.a3 == unquote(main_module).a3 27 | end 28 | 29 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 30 | refute Phone.valid?(unquote("#{code}555123")) 31 | assert {:error, _} = Phone.parse(unquote("#{code}555123")) 32 | 33 | refute unquote(main_module).match?(unquote("#{code}555123")) 34 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555123")) 35 | 36 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 37 | unquote(main_module).build!(unquote("#{code}555123")) 38 | end 39 | end 40 | end) 41 | 42 | Enum.map(all_modules, fn module -> 43 | Enum.map(module.codes, fn code -> 44 | test "#{inspect(module)} parses area code #{code}" do 45 | assert Phone.valid?(unquote("#{code}5551234")) 46 | assert {:ok, parsed} = Phone.parse(unquote("#{code}5551234")) 47 | 48 | assert parsed.country == unquote(main_module).country 49 | assert parsed.a2 == unquote(main_module).a2 50 | assert parsed.a3 == unquote(main_module).a3 51 | assert parsed.area_type == unquote(module).area_type 52 | assert parsed.area_name == unquote(module).area_name 53 | assert parsed.area_abbreviation == unquote(module).area_abbreviation 54 | end 55 | 56 | test "#{inspect(module)} cant parse wrong number with code #{code}" do 57 | refute Phone.valid?(unquote("#{code}555123")) 58 | assert {:error, _} = Phone.parse(unquote("#{code}555123")) 59 | 60 | refute unquote(module).match?(unquote("#{code}555123")) 61 | assert {:error, _} = unquote(module).build(unquote("#{code}555123")) 62 | 63 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 64 | unquote(module).build!(unquote("#{code}555123")) 65 | end 66 | end 67 | end) 68 | end) 69 | end 70 | -------------------------------------------------------------------------------- /test/phone/nanp_test.exs: -------------------------------------------------------------------------------- 1 | defmodule Phone.NANPTest do 2 | use ExUnit.Case, async: true 3 | 4 | main_module = Phone.NANP 5 | 6 | all_modules = [ 7 | Phone.NANP.AS, 8 | Phone.NANP.AI, 9 | Phone.NANP.AG, 10 | Phone.NANP.BS, 11 | Phone.NANP.BB, 12 | Phone.NANP.BM, 13 | Phone.NANP.CA, 14 | Phone.NANP.DM, 15 | Phone.NANP.DO, 16 | Phone.NANP.GD, 17 | Phone.NANP.GU, 18 | Phone.NANP.JM, 19 | Phone.NANP.KN, 20 | Phone.NANP.KY, 21 | Phone.NANP.LC, 22 | Phone.NANP.MP, 23 | Phone.NANP.MS, 24 | Phone.NANP.PR, 25 | Phone.NANP.SX, 26 | Phone.NANP.TC, 27 | Phone.NANP.TT, 28 | Phone.NANP.US, 29 | Phone.NANP.VC, 30 | Phone.NANP.VG, 31 | Phone.NANP.VI, 32 | Phone.NANP.TollFree 33 | ] 34 | 35 | Enum.map(main_module.codes, fn code -> 36 | test "#{inspect(main_module)} cant parse wrong number with code #{code}" do 37 | refute Phone.valid?(unquote("#{code}555123")) 38 | assert {:error, _} = Phone.parse(unquote("#{code}555123")) 39 | 40 | refute unquote(main_module).match?(unquote("#{code}555123")) 41 | assert {:error, _} = unquote(main_module).build(unquote("#{code}555123")) 42 | 43 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 44 | unquote(main_module).build!(unquote("#{code}555123")) 45 | end 46 | end 47 | end) 48 | 49 | Enum.map(all_modules, fn module -> 50 | Enum.map(module.codes, fn code -> 51 | test "#{inspect(module)} parses area code #{code}" do 52 | assert Phone.valid?(unquote("#{code}5551234")) 53 | assert {:ok, parsed} = Phone.parse(unquote("#{code}5551234")) 54 | 55 | assert parsed.country == unquote(module).country 56 | assert parsed.a2 == unquote(module).a2 57 | assert parsed.a3 == unquote(module).a3 58 | end 59 | 60 | test "#{inspect(module)} cant parse wrong number with code #{code}" do 61 | refute Phone.valid?(unquote("#{code}555123")) 62 | assert {:error, _} = Phone.parse(unquote("#{code}555123")) 63 | 64 | refute unquote(module).match?(unquote("#{code}555123")) 65 | assert {:error, _} = unquote(module).build(unquote("#{code}555123")) 66 | 67 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 68 | unquote(module).build!(unquote("#{code}555123")) 69 | end 70 | end 71 | end) 72 | end) 73 | end 74 | -------------------------------------------------------------------------------- /test/phone_test.exs: -------------------------------------------------------------------------------- 1 | defmodule PhoneTest do 2 | use ExUnit.Case, async: true 3 | doctest Phone 4 | 5 | @right_assertion {:ok, 6 | %{ 7 | a2: "HR", 8 | a3: "HRV", 9 | country: "Croatia", 10 | international_code: "385", 11 | area_code: "", 12 | number: "12345678" 13 | }} 14 | @right_return %{ 15 | a2: "HR", 16 | a3: "HRV", 17 | country: "Croatia", 18 | international_code: "385", 19 | area_code: "", 20 | number: "12345678" 21 | } 22 | @wrong_type {:error, "Not a valid parameter, only string or integer."} 23 | @wrong_assertion {:error, "Not a valid phone number."} 24 | 25 | test "parse integer" do 26 | assert Phone.parse(38_512_345_678) == @right_assertion 27 | assert Phone.parse!(38_512_345_678) == @right_return 28 | end 29 | 30 | test "parse not valid integer" do 31 | assert Phone.parse(5532) == @wrong_assertion 32 | assert_raise ArgumentError, "Not a valid phone number.", fn -> Phone.parse!(5532) end 33 | end 34 | 35 | test "parse string with letters" do 36 | assert Phone.parse("abc") == @wrong_assertion 37 | assert_raise ArgumentError, "Not a valid phone number.", fn -> Phone.parse!("abc") end 38 | end 39 | 40 | test "parse string with numbers and letters" do 41 | assert Phone.parse("555112345678abc") == @wrong_assertion 42 | 43 | assert_raise ArgumentError, "Not a valid phone number.", fn -> 44 | Phone.parse!("555112345678abc") 45 | end 46 | end 47 | 48 | test "parse string with formatted number" do 49 | assert Phone.parse("+385 1234 5678") == @right_assertion 50 | assert Phone.parse!("+385 1234 5678") == @right_return 51 | 52 | assert Phone.parse("+385 1234-5678") == @right_assertion 53 | assert Phone.parse!("+385 1234-5678") == @right_return 54 | 55 | assert Phone.parse("+38512345678") == @right_assertion 56 | assert Phone.parse!("+38512345678") == @right_return 57 | end 58 | 59 | test "parse other types" do 60 | assert Phone.parse(:test) == @wrong_type 61 | 62 | assert_raise ArgumentError, "Not a valid parameter, only string or integer.", fn -> 63 | Phone.parse!(:test) 64 | end 65 | 66 | assert Phone.parse({55, 51, 1234, 5678}) == @wrong_type 67 | 68 | assert_raise ArgumentError, "Not a valid parameter, only string or integer.", fn -> 69 | Phone.parse!({55, 51, 1234, 5678}) 70 | end 71 | 72 | assert Phone.parse([55, 51, 1234, 5678]) == @wrong_type 73 | 74 | assert_raise ArgumentError, "Not a valid parameter, only string or integer.", fn -> 75 | Phone.parse!([55, 51, 1234, 5678]) 76 | end 77 | 78 | assert Phone.parse(fn t -> t end) == @wrong_type 79 | 80 | assert_raise ArgumentError, "Not a valid parameter, only string or integer.", fn -> 81 | Phone.parse!(fn t -> t end) 82 | end 83 | end 84 | end 85 | -------------------------------------------------------------------------------- /test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | --------------------------------------------------------------------------------