ecto_shortuuid v0.1.1 Ecto.ShortUUID View Source
An Ecto type for Short UUID strings.
Link to this section Summary
Functions
Casts the given input to the custom type
Converts a string representing a ShortUUID or UUID into a binary
Generates a ShortUUID string based on a version 4 (random) UUID
Converts a binary UUID into a ShortUUID string
The Ecto type
Link to this section Types
raw()
View Source
raw() :: <<_::128>>
raw() :: <<_::128>>
A raw binary representation of a UUID.
shortuuid57()
View Source
shortuuid57() :: <<_::176>>
shortuuid57() :: <<_::176>>
A base57 ShortUUID string.
uuid()
View Source
uuid() :: <<_::288>>
uuid() :: <<_::288>>
A hex-encoded UUID string.
Link to this section Functions
cast(shortuuid)
View Source
cast(shortuuid57() | uuid() | any()) :: {:ok, shortuuid57()} | :error
cast(shortuuid57() | uuid() | any()) :: {:ok, shortuuid57()} | :error
Casts the given input to the custom type.
This callback is called on external input and can return any type,
as long as the dump/1
function is able to convert the returned
value into an Ecto native type. There are two situations where
this callback is called:
- When casting values by
Ecto.Changeset
- When passing arguments to
Ecto.Query
When returning {:error, keyword()}
, the returned keyword list
will be preserved in the changeset errors, similar to
Changeset.add_error/4
. Passing a :message
key, will override
the default message. It is not possible to override the :type
key.
For {:array, CustomType}
or {:map, CustomType}
the returned
keyword list will be erased and the default error will be shown.
Callback implementation for Ecto.Type.cast/1
.
dump(uuid)
View Source
dump(shortuuid57() | uuid() | any()) :: {:ok, raw()} | :error
dump(shortuuid57() | uuid() | any()) :: {:ok, raw()} | :error
Converts a string representing a ShortUUID or UUID into a binary.
generate() View Source
Generates a ShortUUID string based on a version 4 (random) UUID.
load(uuid) View Source
Converts a binary UUID into a ShortUUID string.
type() View Source
The Ecto type.