main
HerrHase 1 year ago
parent f558dd123a
commit 2431dfaef5

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

Loading…
Cancel
Save