Created
April 30, 2013 11:44
-
-
Save gwhitelaw/5488195 to your computer and use it in GitHub Desktop.
Validate UUID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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