Skip to content

Commit a8c665a

Browse files
vdegovethbar
andauthored
IRVE : regex d’email un peu plus stricte (#5513)
Co-authored-by: Thibaut Barrère <thibaut.barrere@gmail.com>
1 parent b4bffb6 commit a8c665a

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

apps/transport/lib/data_frame/validation_primitives.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ defmodule Transport.DataFrame.Validation.Primitives do
6161
Series.re_contains(series, pattern)
6262
end
6363

64-
@simple_email_pattern ~S/(?i)\A[^@\s]+@[^@\s]+\.[^@\s]+\z/
64+
@simple_email_pattern ~S/(?i)\A[^@\s]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}\z/
6565

6666
@doc """
6767
Get the simple email validation pattern.
@@ -80,8 +80,8 @@ defmodule Transport.DataFrame.Validation.Primitives do
8080
iex> email?(build_series(["hello@example.com", "invalid"])) |> Series.to_list()
8181
[true, false]
8282
83-
iex> email?(build_series(["test@foo.bar", "hello@fool"])) |> Series.to_list()
84-
[true, false]
83+
iex> email?(build_series(["test@foo.bar", "hello@fool", "test@foo.bar>"])) |> Series.to_list()
84+
[true, false, false]
8585
"""
8686
def email?(series) do
8787
Series.re_contains(series, @simple_email_pattern)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# mix run scripts/irve/validate_and_summarize.exs
2+
3+
# Change me
4+
file_path = "consolidation_transport_irve_statique.csv"
5+
6+
Transport.LogTimeTaken.log_time_taken("Validating #{file_path}", fn ->
7+
IO.puts("Starting validating downloaded copy of #{file_path}…")
8+
summary = Transport.IRVE.Validator.validate_and_summarize(file_path)
9+
10+
IO.inspect(summary, IEx.inspect_opts())
11+
end)

0 commit comments

Comments
 (0)