Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var myModule = function (merchantId, paymentProductId, postData, paymentContext, cb) {
// validate postData
var isValidRequest = validate(postData, requestSchema);
if (!isValidRequest.valid) {
var logger = sdkcontext.getLogger();
if (sdkcontext.isLoggingEnabled()) {
logger('error', isValidRequest.errors);
}
throw new Error(isValidRequest.errors);
}
communicator.json({
method: 'POST',
modulePath: '/v1/' + merchantId + '/products/' + paymentProductId + '/deviceFingerprint',
body: postData,
paymentContext: paymentContext,
cb: cb
});
}
if ((!LSIF.Edge.is11(edge) && !(LSIF.Edge.is1N(edge))) || edge.outV === undefined) {
// This error was caught before
return;
}
if (edge.label === undefined || !Object.values(LSIF.EdgeLabels).includes(edge.label)) {
errors.push(new Error(edges[key].element, edge.label ? `requires property "label"` : `unknown label`));
edges[key].invalidate();
return;
}
let validation: ValidatorResult;
switch (edge.label) {
case LSIF.EdgeLabels.item:
validation = validateSchema(edge, itemSchema);
break;
case LSIF.EdgeLabels.contains:
validation = validateSchema(edge, e1NSchema);
break;
default:
validation = validateSchema(edge, e11Schema);
}
const validationErrors: ValidationError[] = validation.errors.filter((error) => error.property === 'instance');
if (validationErrors.length > 0) {
edges[key].invalidate();
errors.push(new Error(edges[key].element, validationErrors.join('; ')));
}
});
function validateMeterBarReadingsParams(params) {
const validParams = {
type: 'object',
maxProperties: 1,
required: ['meter_ids'],
properties: {
meter_ids: {
type: 'string',
pattern: '^\\d+(?:,\\d+)*$' // Matches 1 or 1,2 or 1,2,34 (for example)
}
}
};
const paramsValidationResult = validate(params, validParams);
return paramsValidationResult.valid;
}
AbstractMessage.prototype.validate = function() {
return validate(this.getJSON(), this.schema);
};
uniqueItems: true,
items: {
type: 'integer'
},
},
childMeters: {
type: 'array',
uniqueItems: true,
items: {
type: 'integer'
},
}
}
};
if (!validate(req.body, validGroup).valid) {
res.sendStatus(400);
} else {
try {
const currentGroup = await Group.getByID(req.body.id);
const currentChildGroups = await Group.getImmediateGroupsByGroupID(currentGroup.id);
const currentChildMeters = await Group.getImmediateMetersByGroupID(currentGroup.id);
await db.tx(t => {
let nameChangeQuery = [];
if (req.body.name !== currentGroup.name) {
nameChangeQuery = currentGroup.rename(req.body.name, t);
}
const adoptedGroups = _.difference(req.body.childGroups, currentChildGroups);
const adoptGroupsQueries = adoptedGroups.map(gid => currentGroup.adoptGroup(gid));
return;
}
if (edge.label === undefined || !Object.values(LSIF.EdgeLabels).includes(edge.label)) {
errors.push(new Error(edges[key].element, edge.label ? `requires property "label"` : `unknown label`));
edges[key].invalidate();
return;
}
let validation: ValidatorResult;
switch (edge.label) {
case LSIF.EdgeLabels.item:
validation = validateSchema(edge, itemSchema);
break;
case LSIF.EdgeLabels.contains:
validation = validateSchema(edge, e1NSchema);
break;
default:
validation = validateSchema(edge, e11Schema);
}
const validationErrors: ValidationError[] = validation.errors.filter((error) => error.property === 'instance');
if (validationErrors.length > 0) {
edges[key].invalidate();
errors.push(new Error(edges[key].element, validationErrors.join('; ')));
}
});
const isValidEvent = event => validate(event, eventSchema).errors.length === 0;
).filter(i => jsonschema.validate(part, {
...i,
definitions: oas.components && oas.components.schemas
? Object.entries(oas.components.schemas)
.reduce((a, b) => ({ ...a, [b[0]]: isReference(b[1]) ? changeRef(b[1]) : changeRefs(b[1])}), {})
: {},
} ).valid).length > 0;
pokemon.map(function(p) {
jsonValidate(p, schema, { throwError: true })
})
};