Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UUID.valid?/2 #29

Open
christhekeele opened this issue Nov 19, 2017 · 1 comment
Open

UUID.valid?/2 #29

christhekeele opened this issue Nov 19, 2017 · 1 comment

Comments

@christhekeele
Copy link

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.

@librity
Copy link

librity commented Mar 17, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants