Skip to content

Commit 52644b9

Browse files
committed
Added format validation
1 parent cd28c67 commit 52644b9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/validatex/validators.ex

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,13 @@ defmodule Validatex.Validators do
6262
{:error, msg}
6363
end
6464
end
65+
66+
@spec format(raw(), Regex.t(), error_msg()) :: Result.t(error_msg(), raw())
67+
def format(value, %Regex{} = regex, msg) when raw?(value) and error_msg?(msg) do
68+
if value =~ regex do
69+
{:ok, value}
70+
else
71+
{:error, msg}
72+
end
73+
end
6574
end

0 commit comments

Comments
 (0)