Skip to content

Commit

Permalink
fix: 🐛 Correção trace array de validação
Browse files Browse the repository at this point in the history
Correção de bug e atualizado versões das dependências
  • Loading branch information
joaquimsn committed Mar 12, 2021
1 parent 661bad5 commit 8151c44
Show file tree
Hide file tree
Showing 6 changed files with 2,942 additions and 170 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["env"]
}
8 changes: 4 additions & 4 deletions datalayer-validation-core.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const schemaParser = require('./schema-parser');
const Ajv = require('ajv');
const Ajv = require('ajv').default;
const debugging = process.env.PENGUIN_DEBUGGING || false;
let fullValidation = [];

Expand Down Expand Up @@ -170,11 +170,11 @@ function revalidateSchema(shadowSchema, errorMessage, dataLayer, schemaIndex, sc
* @param {*} dataLayer
*/
function checkMissingProperty(schemaItem, dataLayer) {
schemaItem.forEach((item, index, err) => {
schemaItem.forEach((item, index, array) => {
let valid = ajv.validate(item, dataLayer);
let errors = ajv.errors;

trace(`retorno ajv ${JSON.stringify(err)}`);
trace(`retorno ajv ${JSON.stringify(array)}`);
if (!valid) {
errors
.filter((error) => error.schema.constructor === Object && error.keyword === 'required')
Expand All @@ -193,7 +193,7 @@ function checkMissingProperty(schemaItem, dataLayer) {
errorMessage.params.missingProperty
);
} else {
revalidateSchema(shadowSchema, errorMessage, dataLayer, index, arr, dataLayer);
revalidateSchema(shadowSchema, errorMessage, dataLayer, index, array, dataLayer);
}
});
}
Expand Down
Loading

0 comments on commit 8151c44

Please sign in to comment.