Aliases: refactor validate_also_known_as/1

This commit is contained in:
Alex Gleason 2020-12-31 12:53:28 -06:00
parent 0d6b9ce8ca
commit 4200a06340
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 4 additions and 3 deletions

View File

@ -2458,9 +2458,10 @@ def sanitize_html(%User{} = user, filter) do
defp validate_also_known_as(changeset) do
validate_change(changeset, :also_known_as, fn :also_known_as, also_known_as ->
case Enum.all?(also_known_as, fn a -> Regex.match?(@url_regex, a) end) do
true -> []
false -> [also_known_as: "Invalid ap_id format. Must be a URL."]
if Enum.all?(also_known_as, fn a -> Regex.match?(@url_regex, a) end) do
[]
else
[also_known_as: "Invalid ap_id format. Must be a URL."]
end
end)
end