From acb657fac8bfeb9d64e6520c14bea2794a72a1f8 Mon Sep 17 00:00:00 2001 From: Michael van den Berg <5636940+MichaelVanDenBerg@users.noreply.github.com> Date: Fri, 16 Sep 2022 20:46:57 +0200 Subject: [PATCH] Add Dutch names, phone numbers and addresses --- CHANGELOG.md | 3 + USAGE.md | 3 + lib/faker/address/nl.ex | 571 ++++++++++++++++++++++++++++++++++++ lib/faker/person/nl.ex | 418 ++++++++++++++++++++++++++ lib/faker/phone/nl.ex | 91 ++++++ test/faker/address_test.exs | 1 + test/faker/person_test.exs | 1 + test/faker/phone_test.exs | 1 + 8 files changed, 1089 insertions(+) create mode 100644 lib/faker/address/nl.ex create mode 100644 lib/faker/person/nl.ex create mode 100644 lib/faker/phone/nl.ex diff --git a/CHANGELOG.md b/CHANGELOG.md index ef1e56ead..f30955793 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ Change log itself follows [Keep a CHANGELOG](http://keepachangelog.com) format. ### Added - `Faker.Fruits.En` - add english fruits [[@KevinDaSilvaS](https://github.com/KevinDaSilvaS)] +- `Faker.Address.Nl` [[@MichaelVanDenBerg](https://github.com/MichaelVanDenBerg)] +- `Faker.Person.Nl` [[@MichaelVanDenBerg](https://github.com/MichaelVanDenBerg)] +- `Faker.Phone.Nl` [[@MichaelVanDenBerg](https://github.com/MichaelVanDenBerg)] ### Changed - `Faker.Commerce.PtBr` - add more products in product_name_product [[@igorgbr](https://github.com/igorgbr)] diff --git a/USAGE.md b/USAGE.md index a323a03c6..91ec49eb0 100644 --- a/USAGE.md +++ b/USAGE.md @@ -5,6 +5,7 @@ - [Faker.Address.Es](lib/faker/address/es.ex) - [Faker.Address.Hy](lib/faker/address/hy.ex) - [Faker.Address.It](lib/faker/address/it.ex) +- [Faker.Address.Nl](lib/faker/address/nl.ex) - [Faker.Address.PtBr](lib/faker/address/pt_br.ex) - [Faker.Address.Ru](lib/faker/address/ru.ex) - [Faker.Airports](lib/faker/airports.ex) @@ -92,11 +93,13 @@ - [Faker.Person.Es](lib/faker/person/es.ex) - [Faker.Person.Fr](lib/faker/person/fr.ex) - [Faker.Person.Hy](lib/faker/person/hy.ex) +- [Faker.Person.Nl](lib/faker/person/nl.ex) - [Faker.Person.It](lib/faker/person/it.ex) - [Faker.Person.PtBr](lib/faker/person/pt_br.ex) - [Faker.Phone.EnUs](lib/faker/phone/en_us.ex) - [Faker.Phone.EnGb](lib/faker/phone/en_gb.ex) - [Faker.Phone.Hy](lib/faker/phone/hy.ex) +- [Faker.Phone.Nl](lib/faker/phone/nl.ex) - [Faker.Phone.PtBr](lib/faker/phone/pt_br.ex) - [Faker.Pizza](lib/faker/pizza.ex) - [Faker.Pokemon](lib/faker/pokemon.ex) diff --git a/lib/faker/address/nl.ex b/lib/faker/address/nl.ex new file mode 100644 index 000000000..38296e1df --- /dev/null +++ b/lib/faker/address/nl.ex @@ -0,0 +1,571 @@ +defmodule Faker.Address.Nl do + import Faker, only: [sampler: 2] + + alias Faker.Person.Nl, as: Person + + @moduledoc """ + Functions for generating addresses in Dutch + """ + + @doc """ + Return a city name. + + ## Examples + + iex> Faker.Address.Nl.city() + "Katwijk aan Zee" + iex> Faker.Address.Nl.city() + "Wijk bij Duurstede" + iex> Faker.Address.Nl.city() + "Sliedrecht" + iex> Faker.Address.Nl.city() + "Amsterdam" + """ + @spec city() :: String.t() + sampler(:city, [ + "'s-Heerenberg", + "'s-Hertogenbosch", + "Acquoy", + "Alblasserdam", + "Alkmaar", + "Almere", + "Alphen aan den Rijn", + "Amersfoort", + "Amsterdam", + "Amsterdam", + "Anna Paulowna", + "Apeldoorn", + "Arnhem", + "Baarle-Nassau", + "Beesd", + "Bergen op Zoom", + "Breda", + "Brielle", + "Capelle aan den IJssel", + "Castricum", + "Coevoorden", + "Dalfsen", + "Delft", + "Den Haag", + "Den Helder", + "Deventer", + "Doetinchem", + "Dokkum", + "Dordrecht", + "Drachten", + "Ede", + "Eindhoven", + "Emmeloord", + "Emmen", + "Emmer-Compascuum", + "Enschede", + "Gasselterboerveenschemond", + "Geldermalsen", + "Goes", + "Gorinchem", + "Groesbeek", + "Groningen", + "Haarlem", + "Haarlemmermeer", + "Harderwijk", + "Hardinxveld-Giessendam", + "Heerhugowaard", + "Heerlen", + "Hendrik-Ido-Ambacht", + "Hengelo", + "Hilversum", + "Hoogeveen", + "IJmuiden", + "Kampen", + "Katwijk aan Zee", + "Landgraaf", + "Leerdam", + "Leeuwarden", + "Leiden", + "Lelystad", + "Maastricht", + "Meppel", + "Middelburg", + "Naarden", + "Nijkerk", + "Nijmegen", + "Oss", + "Papendrecht", + "Purmerend", + "Roermond", + "Roosendaal", + "Rotterdam", + "Rucphen", + "Ruigoord", + "Sleeuwijk", + "Sliedrecht", + "Sneek", + "Stadskanaal", + "Tilburg", + "Urk", + "Utrecht", + "Valkenburg", + "Veenendaal", + "Venlo", + "Vlaardingen", + "Vlissingen", + "Waalwijk", + "Wageningen", + "Westland", + "Wijk bij Duurstede", + "Wijngaarden", + "Winterswijk", + "Zaanstad", + "Zoetermeer", + "Zwijndrecht", + "Zwolle" + ]) + + @doc """ + Return street address. + + ## Examples + + iex> Faker.Address.Nl.street_address() + "Floortje van Voskade 67" + iex> Faker.Address.Nl.street_address() + "Kalver-erf 181" + iex> Faker.Address.Nl.street_address() + "Dorpkade 170" + iex> Faker.Address.Nl.street_address() + "Lingepark 23" + """ + @spec street_address() :: String.t() + def street_address do + "#{street_name()} #{house_number()}" + end + + @doc """ + Return street name. + + ## Examples + + iex> Faker.Address.Nl.street_name() + "Floortje van Voskade" + iex> Faker.Address.Nl.street_name() + "Rijnplein" + iex> Faker.Address.Nl.street_name() + "Sijmen Hoeklaan" + iex> Faker.Address.Nl.street_name() + "Annekesteeg" + """ + @spec street_name() :: String.t() + def street_name do + street_name(Faker.random_between(0, 9)) + end + + defp street_name(0), + do: "#{Person.first_name()} #{Person.tussenvoegsel()} #{Person.last_name()}#{street_suffix()}" + + defp street_name(1), do: "#{Person.first_name()} #{Person.last_name()}#{street_suffix()}" + defp street_name(2), do: "#{Person.first_name()}#{street_suffix()}" + defp street_name(3), do: "#{Person.last_name()}#{street_suffix()}" + + defp street_name(n) when is_integer(n) do + "#{street_prefix()}#{street_suffix()}" + end + + @doc """ + Return street prefix. + + ## Examples + + iex> Faker.Address.Nl.street_prefix() + "Vis" + iex> Faker.Address.Nl.street_prefix() + "School" + iex> Faker.Address.Nl.street_prefix() + "Hof" + iex> Faker.Address.Nl.street_prefix() + "Haven" + """ + @spec street_prefix() :: String.t() + sampler(:street_prefix, [ + "Aardappel", + "Dorp", + "Gasthuis", + "Graaf", + "Groen", + "Haven", + "Hof", + "IJssel", + "Kalver", + "Kerk", + "Konings", + "Lek", + "Linge", + "Maas", + "Molen", + "Nieuwe", + "Noorder", + "Oude", + "Parallel", + "Rijn", + "School", + "Vis", + "Voor", + "Waal", + "Wijn", + "Zand", + "Zuider" + ]) + + @doc """ + Return street suffix. + + ## Examples + + iex> Faker.Address.Nl.street_suffix() + "dijk" + iex> Faker.Address.Nl.street_suffix() + "-erf" + iex> Faker.Address.Nl.street_suffix() + "park" + iex> Faker.Address.Nl.street_suffix() + "markt" + """ + @spec street_suffix() :: String.t() + sampler(:street_suffix, [ + "dijk", + "-erf", + "kade", + "laan", + "markt", + "park", + "plein", + "steeg", + "straat", + "weg" + ]) + + @doc """ + Return random postcode. + + Dutch zip codes never start with a '0' and always end with two uppercase letters. + + ## Examples + + iex> Faker.Address.Nl.zip_code() + "2110 LR" + iex> Faker.Address.Nl.zip_code() + "8304 EA" + iex> Faker.Address.Nl.zip_code() + "9164 GD" + iex> Faker.Address.Nl.zip_code() + "2380 WZ" + """ + @spec zip_code() :: String.t() + def zip_code do + "#{Faker.random_between(1000, 9999)} ??" + |> Faker.format() + |> String.upcase() + end + + @doc """ + Return building number. + + But since we rarely use building numbers in the Netherlands, this will call 'Faker.Address.Nl.house_number()' instead. + """ + @spec building_number :: String.t() + def building_number, do: house_number() + + @doc """ + Return random house number. + + Dutch house numbers never start with a '0'. + + ## Examples + + iex> Faker.Address.Nl.house_number() + "211" + iex> Faker.Address.Nl.house_number() + "102" + iex> Faker.Address.Nl.house_number() + "136" + iex> Faker.Address.Nl.house_number() + "105" + """ + @spec house_number() :: String.t() + def house_number, do: "#{Faker.random_between(1, 300)}" + + @doc """ + Return a country name. + + Source: https://github.com/faker-ruby/faker + + ## Examples + + iex> Faker.Address.Nl.country() + "Zuidelijke Oceaan" + iex> Faker.Address.Nl.country() + "Sri Lanka" + iex> Faker.Address.Nl.country() + "Maldiven" + iex> Faker.Address.Nl.country() + "Macedonië" + """ + @spec country() :: String.t() + sampler(:country, [ + "Afghanistan", + "Akrotiri", + "Albanië", + "Algerije", + "Amerikaanse Maagdeneilanden", + "Amerikaans-Samoa", + "Andorra", + "Angola", + "Anguilla", + "Antarctica", + "Antigua en Barbuda", + "Noordelijke IJszee", + "Argentinië", + "Armenië", + "Aruba", + "Ashmore- en Cartiereilanden", + "Atlantische Oceaan", + "Australië", + "Azerbeidzjan", + "Bahama's", + "Bahrein", + "Bangladesh", + "Barbados", + "Belarus", + "België", + "Belize", + "Benin", + "Bermuda", + "Bhutan", + "Bolivië", + "Bosnië-Herzegovina", + "Botswana", + "Bouveteiland", + "Brazilië", + "Brits Indische Oceaanterritorium", + "Britse Maagdeneilanden", + "Brunei", + "Bulgarije", + "Burkina Faso", + "Burundi", + "Cambodja", + "Canada", + "Caymaneilanden", + "Centraal-Afrikaanse Republiek", + "Chili", + "China", + "Christmaseiland", + "Clipperton", + "Cocoseilanden", + "Colombia", + "Comoren (Unie)", + "Congo (Democratische Republiek)", + "Congo (Volksrepubliek)", + "Cook", + "Coral Sea Islands", + "Costa Rica", + "Cuba", + "Cyprus", + "Denemarken", + "Dhekelia", + "Djibouti", + "Dominica", + "Dominicaanse Republiek", + "Duitsland", + "Ecuador", + "Egypte", + "El Salvador", + "Equatoriaal-Guinea", + "Eritrea", + "Estland", + "Ethiopië", + "Europese Unie", + "Falkland", + "Faeröer", + "Fiji", + "Filipijnen", + "Finland", + "Frankrijk", + "Frans-Polynesië", + "Franse Zuidelijke en Antarctische Gebieden", + "Gabon", + "Gambia", + "Gaza Strip", + "Georgië", + "Ghana", + "Gibraltar", + "Grenada", + "Griekenland", + "Groenland", + "Guam", + "Guatemala", + "Guernsey", + "Guinea", + "Guinee-Bissau", + "Guyana", + "Haïti", + "Heard en McDonaldeilanden", + "Heilige Stoel", + "Honduras", + "Hongarije", + "Hongkong", + "Ierland", + "IJsland", + "India", + "Indian Ocean", + "Indonesië", + "Irak", + "Iran", + "Isle of Man", + "Israël", + "Italië", + "Ivoorkust", + "Jamaica", + "Jan Mayen", + "Japan", + "Jemen", + "Jersey", + "Jordanië", + "Kaapverdië", + "Kameroen", + "Kazachstan", + "Kenia", + "Kirgizstan", + "Kiribati", + "Koeweit", + "Kroatië", + "Laos", + "Lesotho", + "Letland", + "Libanon", + "Liberia", + "Libië", + "Liechtenstein", + "Litouwen", + "Luxemburg", + "Macao", + "Macedonië", + "Madagaskar", + "Malawi", + "Maldiven", + "Maleisië", + "Mali", + "Malta", + "Marokko", + "Marshalleilanden", + "Mauritanië", + "Mauritius", + "Mayotte", + "Mexico", + "Micronesia, Federale Staten van", + "Moldavië", + "Monaco", + "Mongolië", + "Montenegro", + "Montserrat", + "Mozambique", + "Myanmar", + "Namibië", + "Nauru", + "Navassa", + "Nederland", + "Nederlandse Antillen", + "Nepal", + "Ngwane", + "Nicaragua", + "Nieuw-Caledonië", + "Nieuw-Zeeland", + "Niger", + "Nigeria", + "Niue", + "Noordelijke Marianen", + "Noord-Korea", + "Noorwegen", + "Norfolk (eiland)", + "Oekraïne", + "Oezbekistan", + "Oman", + "Oostenrijk", + "Grote Oceaan", + "Pakistan", + "Palau", + "Panama", + "Papoea-Nieuw-Guinea", + "Paracel Islands", + "Paraguay", + "Peru", + "Pitcairn", + "Polen", + "Portugal", + "Puerto Rico", + "Qatar", + "Roemenië", + "Rusland", + "Rwanda", + "Saint Helena", + "Saint Lucia", + "Saint Vincent en de Grenadines", + "Saint-Pierre en Miquelon", + "Salomon", + "Samoa", + "San Marino", + "São Tomé en Principe", + "Saudi-Arabië", + "Senegal", + "Servië", + "Seychellen", + "Sierra Leone", + "Singapore", + "Sint-Kitts en Nevis", + "Slovenië", + "Slowakije", + "Soedan", + "Somalië", + "South Georgia and the South Sandwich Islands", + "Zuidelijke Oceaan", + "Spanje", + "Spratly Islands", + "Sri Lanka", + "Suriname", + "Svalbard", + "Syrië", + "Tadzjikistan", + "Taiwan", + "Tanzania", + "Thailand", + "Timor Leste", + "Togo", + "Tokelau", + "Tonga", + "Trinidad en Tobago", + "Tsjaad", + "Tsjechië", + "Tunesië", + "Turkije", + "Turkmenistan", + "Turks-en Caicoseilanden", + "Tuvalu", + "Uganda", + "Uruguay", + "Vanuatu", + "Venezuela", + "Verenigd Koninkrijk", + "Verenigde Arabische Emiraten", + "Verenigde Staten van Amerika", + "Vietnam", + "Wake (eiland)", + "Wallis en Futuna", + "Wereld", + "Westelijke Jordaanoever", + "Westelijke Sahara", + "Zambia", + "Zimbabwe", + "Zuid-Afrika", + "Zuid-Korea", + "Zweden", + "Zwitserland" + ]) +end diff --git a/lib/faker/person/nl.ex b/lib/faker/person/nl.ex new file mode 100644 index 000000000..70aa015af --- /dev/null +++ b/lib/faker/person/nl.ex @@ -0,0 +1,418 @@ +defmodule Faker.Person.Nl do + import Faker, only: [sampler: 2] + + @moduledoc """ + Functions for name data in Dutch + """ + + @doc """ + Returns a complete name (may include a suffix/prefix or both) + + ## Examples + iex> Faker.Person.Nl.name() + "Floortje van Vos" + iex> Faker.Person.Nl.name() + "Beatrix van de Klein" + iex> Faker.Person.Nl.name() + "Sijmen Hoek" + iex> Faker.Person.Nl.name() + "Theo Brouwer" + """ + @spec name() :: String.t() + def name, do: name(Faker.random_between(0, 15)) + defp name(0), do: "#{prefix()} #{first_name()} #{tussenvoegsel()} #{last_name()} #{suffix()}" + defp name(1), do: "#{prefix()} #{first_name()} #{last_name()} #{suffix()}" + defp name(2), do: "#{first_name()} #{tussenvoegsel()} #{last_name()} #{suffix()}" + defp name(3), do: "#{first_name()} #{last_name()} #{suffix()}" + + defp name(n) when is_integer(n) and n < 9, + do: "#{first_name()} #{tussenvoegsel()} #{last_name()}" + + defp name(n) when is_integer(n) do + "#{first_name()} #{last_name()}" + end + + @doc """ + Returns a random first name + + ## Examples + + iex> Faker.Person.Nl.first_name() + "Adriaan" + iex> Faker.Person.Nl.first_name() + "Floortje" + iex> Faker.Person.Nl.first_name() + "Bas" + iex> Faker.Person.Nl.first_name() + "Sietske" + """ + @spec first_name() :: String.t() + sampler(:first_name, [ + "Adriaan", + "Amber", + "Anna", + "Anne", + "Anneke", + "Annefleur", + "Annelies", + "Annemiek", + "Anouk", + "Arnoud", + "Bas", + "Beatrix", + "Benjamin", + "Benthe", + "Boudewijn", + "Bram", + "Britt", + "Carlijn", + "Carolien", + "Chantal", + "Charlotte", + "Christine", + "Claire", + "Cor", + "Cornelia", + "Cornelis", + "Daan", + "Daniël", + "David", + "Diederik", + "Dick", + "Dirk", + "Doutzen", + "Egbert-Jan", + "Emma", + "Esmee", + "Eva", + "Femke", + "Finn", + "Fleur", + "Floor", + "Floortje", + "Floris", + "Froukje", + "Gerard", + "Gerben", + "Gerrit", + "Hendrik", + "Hans", + "Henk-Jan", + "Hidde", + "Iris", + "Isa", + "Jan", + "Janna", + "Janneke", + "Jasmijn", + "Jasper", + "Jayden", + "Jesse", + "Jetske", + "Johannes", + "Jolanda", + "Joop", + "Joost", + "Julia", + "Julian", + "Karel", + "Karlijn", + "Kees", + "Kevin", + "Koen", + "Lars", + "Laurentine", + "Levi", + "Lia", + "Lieke", + "Lieve", + "Lisa", + "Lisanne", + "Lisette", + "Liza", + "Lodewijk", + "Lotte", + "Lucas", + "Luuk", + "Maartje", + "Madelief", + "Maikel", + "Maria", + "Marie-Claire", + "Martine", + "Maud", + "Maurits", + "Max", + "Merel", + "Michelle", + "Mike", + "Milan", + "Mohamed", + "Nathalie", + "Nick", + "Nicolaas", + "Niels", + "Nienke", + "Noa", + "Pascalle", + "Paul", + "Pien", + "Piet", + "Pieter", + "Pim", + "Reinier", + "Renske", + "Ria", + "Rianne", + "Rick", + "Robbert", + "Robert-Jan", + "Roderick", + "Ronald", + "Roos", + "Rozemarijn", + "Ruben", + "Sander", + "Sandra", + "Sanne", + "Sebastiaan", + "Sem", + "Sietske", + "Sijmen", + "Sjoukje", + "Sophie", + "Sterre", + "Stijn", + "Sven", + "Tess", + "Theo", + "Thijs", + "Thomas", + "Tim", + "Tineke", + "Tom", + "Tooske", + "Twan", + "Victor", + "Vincent", + "Viviènne", + "Vlinder", + "Walram", + "Wilhelmina", + "Willem", + "Willemijn", + "Yinthe", + "Zwaantje" + ]) + + @doc """ + Returns a random tussenvoegsel + + ## Examples + + iex> Faker.Person.Nl.tussenvoegsel() + "van der" + iex> Faker.Person.Nl.tussenvoegsel() + "den" + iex> Faker.Person.Nl.tussenvoegsel() + "van" + iex> Faker.Person.Nl.tussenvoegsel() + "de" + """ + @spec tussenvoegsel() :: String.t() + sampler(:tussenvoegsel, [ + "de", + "den", + "ter", + "van", + "van de", + "van den", + "van der", + "van 't" + ]) + + @doc """ + Returns a random last name + + ## Examples + + iex> Faker.Person.Nl.last_name() + "Vliet" + iex> Faker.Person.Nl.last_name() + "Willems" + iex> Faker.Person.Nl.last_name() + "Hond" + iex> Faker.Person.Nl.last_name() + "Vos" + """ + @spec last_name() :: String.t() + sampler(:last_name, [ + "Aalbersberg", + "Aartsen", + "Achteren", + "Bakker", + "Beek", + "Beekhuis", + "Besseling", + "Berg", + "Bergen", + "Bergh", + "Boer", + "Boogaard", + "Boom", + "Bos", + "Bosch", + "Boudewijn", + "Brink", + "Broeders", + "Broek", + "Brouwer", + "Bruin", + "Buijtenhek", + "Dam", + "Dekker", + "Dijk", + "Dijkstra", + "Driel", + "Driessen", + "Ebbenhorst", + "Ellemeet", + "Gelderland", + "Genderen", + "Giersbergen", + "Graaf", + "Groot", + "Haan", + "Hendriks", + "Heuvel", + "Hoek", + "Hond", + "Hoppenbrouwer", + "Houwelingen", + "Huijbrechts", + "Huisman", + "IJzendoorn", + "Jacobs", + "Jansen", + "Janssen", + "Jong", + "Keizer", + "Klein", + "Kok", + "Koning", + "Kortekaas", + "Koster", + "Kroes", + "Kruijthoff", + "Leeuwen", + "Leeuwenburg", + "Lelivelt", + "Linden", + "Maas", + "Marijnissen", + "Markenstein", + "Mastenbroek", + "Meer", + "Meersbergen", + "Meijer", + "Meulenberg", + "Molenaar", + "Mulder", + "Naaktgeboren", + "Nijland", + "Oldenbarneveld", + "Oosterhout", + "Paulusma", + "Peters", + "Pijnenburg", + "Poelman", + "Ravenhorst", + "Ridder", + "Rijn", + "Ruiter", + "Rutte", + "Schaapstra", + "Schilder", + "Schimmelpenninck", + "Schouten", + "Simons", + "Singh", + "Smit", + "Smits", + "Spijkerman", + "Stellingwerff", + "Stichting", + "Stokvis", + "Tan", + "Timmermans", + "Tjeerdsma", + "Vaatstra", + "Veen", + "Ven", + "Vermeulen", + "Vis", + "Visser", + "Vliet", + "Voorst tot Voorst", + "Vos", + "Vries", + "Waalwijk", + "Westerling", + "Wietmarschen", + "Wal", + "Willems", + "Willemstein", + "Winter", + "Wit", + "Witteman", + "Yilmaz", + "Zanten", + "Zee", + "Zwijnenburg", + "Zwolle" + ]) + + @doc """ + Returns a random prefix + + ## Examples + + iex> Faker.Person.Nl.prefix() + "Dhr." + iex> Faker.Person.Nl.prefix() + "Mevr." + iex> Faker.Person.Nl.prefix() + "Dhr." + iex> Faker.Person.Nl.prefix() + "Drs." + """ + @spec prefix() :: String.t() + sampler(:prefix, [ + "Dhr.", + "Mevr.", + "Mr.", + "Ing.", + "Drs." + ]) + + @doc """ + Returns a random suffix + + ## Examples + + iex> Faker.Person.Nl.suffix() + "Jr." + iex> Faker.Person.Nl.suffix() + "PhD" + iex> Faker.Person.Nl.suffix() + "Jr." + iex> Faker.Person.Nl.suffix() + "PhD" + """ + @spec suffix() :: String.t() + sampler(:suffix, [ + "Jr.", + "Sr.", + "PhD" + ]) +end diff --git a/lib/faker/phone/nl.ex b/lib/faker/phone/nl.ex new file mode 100644 index 000000000..e70244d89 --- /dev/null +++ b/lib/faker/phone/nl.ex @@ -0,0 +1,91 @@ +defmodule Faker.Phone.Nl do + import Faker, only: [samplerp: 2] + + @moduledoc """ + Functions for generating phone related data for the Netherlands + """ + + @doc """ + Returns a random phone number. + + ## Examples + + iex> Faker.Phone.Nl.number() + "0495542646" + iex> Faker.Phone.Nl.number() + "0683297052" + iex> Faker.Phone.Nl.number() + "0031670203032" + iex> Faker.Phone.Nl.number() + "0707337603" + """ + + @spec number() :: String.t() + def number do + if Faker.random_between(0, 1) == 0 do + landline_number() + else + cell_number() + end + end + + samplerp(:landline_number_format, [ + "010#######", + "020#######", + "024#######", + "0342######", + "038#######", + "0495######", + "050#######", + "070#######", + "078#######", + "085#######", + "088#######", + "003110#######" + ]) + + @doc """ + Returns a random landline phone number + + ## Examples + + iex> Faker.Phone.Nl.landline_number() + "0501542646" + iex> Faker.Phone.Nl.landline_number() + "0342083297" + iex> Faker.Phone.Nl.landline_number() + "0505235702" + iex> Faker.Phone.Nl.landline_number() + "0883032097" + """ + + @spec landline_number() :: String.t() + def landline_number do + Faker.format(landline_number_format()) + end + + samplerp(:cell_number_format, [ + "06########", + "00316########" + ]) + + @doc """ + Returns a random cell phone number + + ## Examples + + iex> Faker.Phone.Nl.cell_number() + "0615426461" + iex> Faker.Phone.Nl.cell_number() + "0683297052" + iex> Faker.Phone.Nl.cell_number() + "0031657020303" + iex> Faker.Phone.Nl.cell_number() + "0609733760" + """ + + @spec cell_number() :: String.t() + def cell_number do + Faker.format(cell_number_format()) + end +end diff --git a/test/faker/address_test.exs b/test/faker/address_test.exs index dec47b551..cf9f2181d 100644 --- a/test/faker/address_test.exs +++ b/test/faker/address_test.exs @@ -6,6 +6,7 @@ defmodule Faker.AddressTest do doctest Faker.Address.Es doctest Faker.Address.Hy doctest Faker.Address.It + doctest Faker.Address.Nl doctest Faker.Address.PtBr doctest Faker.Address.Ru end diff --git a/test/faker/person_test.exs b/test/faker/person_test.exs index 3c9c4d678..0464d0264 100644 --- a/test/faker/person_test.exs +++ b/test/faker/person_test.exs @@ -7,5 +7,6 @@ defmodule Faker.PersonTest do doctest Faker.Person.Fr doctest Faker.Person.Hy doctest Faker.Person.It + doctest Faker.Person.Nl doctest Faker.Person.PtBr end diff --git a/test/faker/phone_test.exs b/test/faker/phone_test.exs index b52949916..aeb1f610d 100644 --- a/test/faker/phone_test.exs +++ b/test/faker/phone_test.exs @@ -4,5 +4,6 @@ defmodule Faker.PhoneTest do doctest Faker.Phone.EnGb doctest Faker.Phone.EnUs doctest Faker.Phone.Hy + doctest Faker.Phone.Nl doctest Faker.Phone.PtBr end