1
0
Fork 1
mirror of https://akkoma.dev/AkkomaGang/akkoma.git synced 2024-12-25 04:53:06 +00:00

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

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