Fixed datapath access for when path starts with array

This commit is contained in:
Vishal Shingala
2020-06-09 21:21:12 +05:30
parent e16f2c9488
commit bece1e3f06

View File

@@ -2363,6 +2363,13 @@ module.exports = {
// Filter validation errors for following cases
filteredValidationError = _.filter(_.get(validate, 'errors', []), (validationError) => {
let dataPath = _.get(validationError, 'dataPath', '');
// discard the leading '.' if it exists
if (dataPath[0] === '.') {
dataPath = dataPath.slice(1);
}
// for invalid `propertyNames` two error are thrown by Ajv, which include error with `pattern` keyword
if (validationError.keyword === 'pattern') {
return !_.has(validationError, 'propertyName');
@@ -2376,7 +2383,7 @@ module.exports = {
// Ignore unresolved variables from mismatch if option is set
else if (options.ignoreUnresolvedVariables &&
this.isPmVariable(_.get(valueToUse, validationError.dataPath.slice(1)))) {
this.isPmVariable(_.get(valueToUse, dataPath))) {
return false;
}
return true;