@ermitsrl/bluetooth-le
Version:
Capacitor plugin for Bluetooth Low Energy
12 lines • 522 B
JavaScript
export function validateUUID(uuid) {
if (typeof uuid !== 'string') {
throw new Error(`Invalid UUID type ${typeof uuid}. Expected string.`);
}
uuid = uuid.toLowerCase();
const is128BitUuid = uuid.search(/^[0-9a-f]{8}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{12}$/) >= 0;
if (!is128BitUuid) {
throw new Error(`Invalid UUID format ${uuid}. Expected 128 bit string (e.g. "0000180d-0000-1000-8000-00805f9b34fb").`);
}
return uuid;
}
//# sourceMappingURL=validators.js.map