Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Validate UUID
validateUuid = (text) -> (text || "").match(/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/)
validateUuid(null) # returns null
validateUuid("") # returns null
validateUuid("not-a-valid-uuid") # returns null
validateUuid("73963155-27db-48ad-abee-7afa2dd14af1") # returns regex match array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.