Fix prefix validation in Ecto type

This commit is contained in:
Andrew Timberlake 2024-08-27 13:32:22 +02:00
parent c74d433c2d
commit 154833ce1c
2 changed files with 2 additions and 5 deletions

View file

@ -263,7 +263,7 @@ defmodule TypeID do
ArgumentError -> :error
end
defp validate_prefix!(prefix) do
def validate_prefix!(prefix) do
cond do
String.starts_with?(prefix, "_") ->
invalid_prefix!(prefix, "cannot start with an underscore")

View file

@ -89,10 +89,7 @@ if Code.ensure_loaded?(Ecto.ParameterizedType) do
prefix = Keyword.get(opts, :prefix)
if primary_key do
unless prefix && prefix =~ ~r/^[a-z]{0,63}$/ do
raise ArgumentError,
"must specify `prefix` using only lowercase letters between 0 and 63 characters long."
end
TypeID.validate_prefix!(prefix)
end
unless type in ~w[string binary]a do