Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function assertXML(xml) {
const err = parser.validate(xml);
if (err !== true) {
// console.error(xml);
throw new Chai.AssertionError(err.err.code + ": " + err.err.msg);
}
}
it('should return valid xml when sane inputs provided', () => {
expect(parser.validate(toSVG(network, options))).toBe(true);
});
});
test: (contentType: string, content: string) => {
const doesContentTypeMatch = !!typeIs.is(contentType, [
'application/xml',
'application/*+xml',
'text/xml',
]);
const isContentXML = parser.validate(content) === true;
return doesContentTypeMatch || isContentXML;
},
validate: (expected: Result, output: Result) => {
function validateSyntax(fileName) {
try {
if (fileName.endsWith(".json")) {
require('jsonlint').parse(fs.readFileSync(fileName, {
encoding: 'utf-8'
}));
console.log("Validated successfully");
} else if (fileName.endsWith(".yaml") || fileName.endsWith(".yml")) {
require('yamljs').parseFile(fileName);
console.log("Validated successfully");
}else if(fileName.endsWith(".xml")){
var result = require('fast-xml-parser').validate(fs.readFileSync(fileName, {
encoding: 'utf-8'
}));
if(result === true) {
console.log("Validated successfully");
}else{
console.log("Validation failed");
}
}else {
console.log("Unsupported file");
}
} catch (e) {
console.log("Validation failed");
console.log(color(e, 'red'));
//if(e.line) console.log("line number: " + e.line + ":" + e.column);
}
}
if (typeof options === 'string') {
params.outputType = options;
} else if (typeof options === 'object') {
extend(params, options)
}
var target = args[0];
if (target && !isDef(params.dataType)) {
if (typeof target === 'string') {
target = target.replace(/^[\s\xa0]+|[\s\xa0]+$/g, '');
try {
JSON.parse(target);
params.dataType = 'json';
} catch (e) {
if (fastXmlParser.validate(target)) {
if (target.lastIndexOf('
function (error, response, body) {
if (parser.validate(body)) {
var jsonObj = parser.parse(body);
var device;
for (var i = 0; i < jsonObj.OTA.manufacturer.length; i++) {
if (jsonObj.OTA.manufacturer[i][keywords]) {
device = jsonObj.OTA.manufacturer[i][keywords];
break;
}
}
if (device) {
request.get(device.download, {
followRedirect: false
},
function (error, response, body) {
export function addToSSML(ssml: string|undefined, statement: string): string {
let reply: string;
ssml = ssml || "";
const base = ssml.replace(/^([\s\S]*)<\/speak>$/g, "$1");
statement = statement.replace(/&/g, "&");
if (!base) {
reply = `${statement}`;
} else {
reply = `${base}\n${statement}`;
}
const validationResult = parser.validate(reply);
if (validationResult === true) {
return reply;
}
throw new SSMLError(validationResult.err.msg, reply);
}
var isValidXML = function(value) {
return value ? xmlParser.validate(value) : false;
};