elixir-uuid
elixir-uuid copied to clipboard
UUID.valid?/2
It'd be handy for this library to provide some basic validation functions for uuids, too.
Might hack this together shortly, wanted to leave this here to remind myself in case I don't get around to it soon or somebody else want to take a stab at it.
I'm thinking it could support :version and :format opts––the format one to verify that the uuid is of a particular format, not to hint at the format of the argument for parsing purposes.
I couldn't agree more. I created a helper method using UUID.info/1, but it's far from ideal:
defmodule MyApp.Aux.ValidateUUID do
def call(uuid) do
case UUID.info(uuid) do
{:ok, [{:uuid, valid_uuid} | _tails]} -> {:ok, valid_uuid}
{:error, _reason} = error -> error
end
end
end