Fix prefix validation in Ecto type (#35)

This commit is contained in:
Andrew Timberlake 2024-08-28 18:10:40 +02:00 committed by GitHub
parent c74d433c2d
commit 1e4d1f8aee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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