reshuffle-eidr-connector
Version:
Reshuffle connectors for eidr.org
24 lines • 742 B
JavaScript
;
exports.__esModule = true;
exports.validateId = void 0;
// Validate an EIDR content or other ID with the
// following formats:
//
// 10.5240/xxxx-xxxx-xxxx-xxxx-xxxx-y
// 10.5238/xxxx-xxxx
// 10.5237/xxxx-xxxx
//
// where every 'x' is a hexadecimal digit (0-F) and 'y' is
// any digit (0-9) or a capital letter (A-Z).
//
// @param ID EIDR ID string
//
// @return true for valid IDs, false otherwise
//
function validateId(id) {
var contentRe = /^10\.5240\/([0-9A-F]{4}-){5}[0-9A-Z]$/;
var otherRe = /^10\.523[79]\/[0-9A-F]{4}-[0-9A-F]{4}$/;
return typeof id === 'string' && (contentRe.test(id) || otherRe.test(id));
}
exports.validateId = validateId;
//# sourceMappingURL=validate.js.map