Check if json or xml is a valid oembed response
npm install oembed-validatorThis is a simple utility called "oEmbed Validator". It checks if a given JSON or XML is a valid oEmbed response.
``bash`
npm install oembed-validatoror
yarn install oembed-validator
To use this utility, simply import it in your JavaScript file and call the main function with the JSON or XML data you want to validate.
`javascript{
// Example usage
const response =
"version": "1.0",
"type": "video",
"provider_name": "YouTube",
"provider_url": "https://youtube.com/",
"width": 425,
"height": 344,
"title": "Amazing Nintendo Facts",
"url": "test", // extra field
"author_name": "ZackScott",
"author_url": "https://www.youtube.com/user/ZackScott",
"html": ""
};
// Import the function
const {validateOEmbedResponse} = require('oembed-validator');
// Call the function
validateOEmbedResponse(200, response, true).then((result) => {
console.log('Result:', result);
}).catch((error) => {
console.error('Error:', error);
});
`
This project depends on the xml2js` library for parsing XML data.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the ISC license.