main
HerrHase 2 years ago
parent f558dd123a
commit 2431dfaef5

@ -72,26 +72,24 @@ class Filter {
_in(value, key, result) { _in(value, key, result) {
let isValid = false let isValid = false
if (!result[key]) { if (result[key]) {
isValid = false if (Array.isArray(value)) {
} let found = false
if (Array.isArray(value)) { // run through array
let found = false value.forEach((v, index) => {
if (result[key].indexOf(v) !== -1) {
// run through array found = true
value.forEach((v, index) => { }
if (result[key].indexOf(v) !== -1) { })
found = true
if (found) {
isValid = true
}
} else {
if (result[key].indexOf(value) !== -1) {
isValid = true
} }
})
if (found) {
isValid = true
}
} else {
if (result[key].indexOf(value) !== -1) {
isValid = true
} }
} }

@ -54,6 +54,21 @@ describe('Filter', function () {
assert.equal(filter.validate(data), true) assert.equal(filter.validate(data), true)
}) })
it('_in single, missing tags', function() {
const filter = new Filter({
tags: {
_in: 'monday'
}
})
const data = {
name: 'monday'
}
assert.equal(filter.validate(data), false)
})
it('_in array', function() { it('_in array', function() {
const filter = new Filter({ const filter = new Filter({

Loading…
Cancel
Save