A small package for checking if a string is a valid GUID.
npm install check-is-guid
yarn add check-is-guid
const checkIsGuid = require('check-is-guid');
checkIsGuid('f4090a94-1774-46d7-b469-109ddec68cd2'); // true
checkIsGuid('f4090a94-1774-46d7-b469-109ddec68cd'); // false
import checkIsGuid from 'check-is-guid';
checkIsGuid('f4090a94-1774-46d7-b469-109ddec68cd2'); // true
checkIsGuid('f4090a94-1774-46d7-b469-109ddec68cd'); // false
Add an optional version argument to also confirm the GUID is a specific version.
checkIsGuid('f4090a94-1774-46d7-b469-109ddec68cd2', {version: 4}); // true
checkIsGuid('f4090a94-1774-46d7-b469-109ddec68cd2', {version: 5}); // false