Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
validator.attributes.noDuplicatePropertyValuesFor = function (instance, schema, options, ctx) {
var result = new jsonschema.ValidatorResult(instance, schema, options, ctx);
if (_.isString(schema.noDuplicatePropertyValuesFor)) {
schema.noDuplicatePropertyValuesFor = [schema.noDuplicatePropertyValuesFor];
}
if (!_.isArray(schema.noDuplicatePropertyValuesFor) || !_.isArray(instance)) {
return result;
}
_.each(schema.noDuplicatePropertyValuesFor, function (prop) {
var duplicates = _.chain(instance).countBy(function (component) {
return component[prop];
}).map(function (count, value) {
if (count > 1) {
return value;
}
validator.attributes.isFunction = function (instance, schema, options, ctx) {
var result = new jsonschema.ValidatorResult(instance, schema, options, ctx);
if (!_.isBoolean(schema.isFunction)) {
return result;
}
if (schema.isFunction) {
if ((instance !== undefined) && (typeof instance !== 'function')) {
result.addError('Required to be a function.');
}
}
else {
if (typeof instance === 'function') {
result.addError('Required to not be a function.');
}
}