ansman / validate.js

A declarative validation library written javascript
https://validatejs.org
MIT License
2.62k stars 337 forks source link

Requesting UUID/GUID v4 validator (regex inside) #299

Open alystair opened 5 years ago

alystair commented 5 years ago

Version 4 UUIDs have the form xxxxxxxx-xxxx-4xxx-Yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and y is one of 8, 9, a, or b.

Regex equiv /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i

jakerobers commented 4 years ago

Alternatively you can use validator's function. They have a lot of string validations.