Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
BaseTypeValidator.prototype.validate = function (obj, context, path) {
if (path === void 0) { path = ''; }
obj = cloneDeep(obj);
var validatorPromises = [];
// if the object under validation does not exist return default result
if (!json_pointer_1.has(obj, path))
return validatorPromises;
var targetValue = json_pointer_1.get(obj, path);
// loops over validators and build the validation result
Object.values(this.validationRules).forEach(function (validationRule) {
validatorPromises.push(validationRule(targetValue, obj, path, context));
});
return validatorPromises;
};
return BaseTypeValidator;
validate (value: any, context: Context, path: string = ''): Promise[] {
value = cloneDeep(value)
let results = super.validate(value, context, path)
if (has(value, path)) {
// validating each entry
results = results.concat(this.allItemsValidator.validate(value, context, path))
}
this.singleItemValidators.forEach(validator => {
results = results.concat(validator.validate(value, path, context))
})
return results
}
async _GET (path) {
let result = null;
if (path === '/') return this.state;
try {
result = pointer.get(this.state, path);
} catch (E) {
this.error(`Could not _GET() ${path}:`, E);
}
return result;
}
Object.keys(this.keyValidators).forEach(propertyName => {
const typeValidator = this.keyValidators[ propertyName ]
const propertyPath = [ path, propertyName ].join('/')
if (has(obj, propertyPath) && get(obj, propertyPath) !== null) {
propertiesResults = propertiesResults.concat(typeValidator.validate(obj, context, propertyPath))
}
})
validate (obj: any, context: Context, path: string = ''): Promise[] {
obj = cloneDeep(obj)
if (path !== '') {
set(obj, path, this.parse(get(obj, path)))
return super.validate(obj, context, path)
} else {
return super.validate(this.parse(obj), context, path)
}
}
}
export function get(entity: any, path: string): any {
return jsonPointer.get(entity, path);
}
this.requiredProps.forEach(function (property) {
if (!json_pointer_1.has(obj, path + "/" + property) || json_pointer_1.get(obj, path + "/" + property) === null) {
context.addError('object.requires', path, { property: property });
}
});
var superResult = _super.prototype.validate.call(this, obj, context, path);
confirmed: () => (value: string, obj: any, path: string): boolean => {
const confirmPath = `${path}_confirmation`
return (has(obj, path) && has(obj, confirmPath) && get(obj, path) === get(obj, confirmPath))
},
}
this.requiredProps.forEach(property => {
if (!has(obj, `${path}/${property}`) || get(obj, `${path}/${property}`) === null) {
context.addError('object.requires', path, { property })
}
})
exports.getData = function (state, props) {
var schemaKey = props.schemaKey, mergeSchema = props.mergeSchema;
var _a = mergeSchema.keys, keys = _a === void 0 ? [] : _a;
var _b = state[props.schemaKey].data, data = _b === void 0 ? {} : _b;
return jpp.has(data, jpp.compile(keys)) ? jpp.get(data, jpp.compile(keys)) : undefined;
};
/**