Open dkran opened 9 years ago
I've run into the same issue... It's a problem with the generated code giving options {filter: true}
to validator
doesn't work either. Ie. validator(schema, {filter: true, verbose: true})
, it just ignores any type errors.
As a temporary work around I'm doing:
var validator = require('is-my-json-valid')
var filter = validator.filter(schema);
var validate = validator(schema, {
verbose: true,
greedy: true
});
var filterAndValidate = function(data) {
filter(data);
validate(data);
console.log(validate.errors);
};
It's obviously slower, so not a fix... Just including it as context.
I have something similar going on as a workaround. I also started poking around at the imjv source to see if I could trace it back, but it's a bit confusing to me.
I wish this was getting a little attention here.
I have a small validator written as such:
Long story short, if I take off the .filter, it will throw errors if I take off required fields and the like, but also throw errors on fields that need to be stripped. if I put filter on, it seems the validator won't pass, but the errors array is always undefined.
simple route logic right now just to test this is:
my actual code is commented out