UNPKG

@mikezimm/fps-core-v7

Version:

Library of reusable core interfaces, types and constants migrated from fps-library-v2

15 lines 712 B
/** * This is a simple guid checker assuming if it is a guid, it's not manually typed in so it should work. * It's also NOT checking if the string meets any criteria other than it has at least one character... * aka any character makes it a title if it's not a guid * If you need 100% compliance checking for proper guid syntax, use src\logic\Strings\guids * @param str * @returns */ export function isStringGuidOrTitle(str) { if (!str || typeof str !== 'string') return 'none'; const guidRegex = /^\{?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}?$/i; return guidRegex.test(str) ? 'guid' : 'title'; } //# sourceMappingURL=isStringGuidOrTitle.js.map