UNPKG

@metamask/snaps-sdk

Version:

A library containing the core functionality for building MetaMask Snaps

23 lines 777 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.svg = void 0; const superstruct_1 = require("@metamask/superstruct"); /** * Get a Struct that validates a string as a valid SVG. * * @returns A Struct that validates a string as a valid SVG. * @internal */ function svg() { return (0, superstruct_1.refine)((0, superstruct_1.string)(), 'SVG', (value) => { // This validation is intentionally very basic, we don't need to be that strict // and merely have this extra validation as a helpful error if devs aren't // passing in SVGs. if (!value.includes('<svg')) { return 'Value is not a valid SVG.'; } return true; }); } exports.svg = svg; //# sourceMappingURL=svg.cjs.map