validar = {
function validarManifiestoIIIF(manifiesto) {
const requiredKeys = ["@context", "@id", "@type"];
for (const key of requiredKeys) {
if (!manifiesto.hasOwnProperty(key)) {
return false;
}
}
const contextRegex = /^https?:\/\/.+$/;
const idRegex = /^https?:\/\/.+$/;
const typeRegex = /^[a-zA-Z]+:[a-zA-Z]+$/;
if (!contextRegex.test(manifiesto["@context"]) || !idRegex.test(manifiesto["@id"]) || !typeRegex.test(manifiesto["@type"])) {
return false;
}
return true;
}
const manifiestoEjemplo = await d3.json("https://www.loc.gov/item/2021670010/manifest.json")
return validarManifiestoIIIF(manifiestoEjemplo)
}