|
|
|
@ -1,10 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
class Filter {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param {object} options
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
constructor(options) {
|
|
|
|
|
this._options = options
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* if result with key is equal
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param {object} value
|
|
|
|
|
* @param {string} key
|
|
|
|
|
* @param {object} result
|
|
|
|
|
*
|
|
|
|
|
* @return {boolean}
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
_eq(value, key, result) {
|
|
|
|
|
let isValid = false
|
|
|
|
|
|
|
|
|
@ -15,6 +36,17 @@ class Filter {
|
|
|
|
|
return isValid
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* if result with key is not equal
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param {object} value
|
|
|
|
|
* @param {string} key
|
|
|
|
|
* @param {object} result
|
|
|
|
|
*
|
|
|
|
|
* @return {boolean}
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
_neq(value, key, result) {
|
|
|
|
|
let isValid = false
|
|
|
|
|
|
|
|
|
@ -25,6 +57,18 @@ class Filter {
|
|
|
|
|
return isValid
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* if result with key has a single value or
|
|
|
|
|
* value from value
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param {object} value
|
|
|
|
|
* @param {string} key
|
|
|
|
|
* @param {object} result
|
|
|
|
|
*
|
|
|
|
|
* @return {boolean}
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
_in(value, key, result) {
|
|
|
|
|
let isValid = false
|
|
|
|
|
|
|
|
|
@ -55,7 +99,137 @@ class Filter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* if result with key is lesser
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param {object} value
|
|
|
|
|
* @param {string} key
|
|
|
|
|
* @param {object} result
|
|
|
|
|
*
|
|
|
|
|
* @return {boolean}
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
_lt(value, key, result) {
|
|
|
|
|
let isValid = false
|
|
|
|
|
|
|
|
|
|
if (result[key] > value) {
|
|
|
|
|
isValid = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return isValid
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* if result with key is lesser or equal
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param {object} value
|
|
|
|
|
* @param {string} key
|
|
|
|
|
* @param {object} result
|
|
|
|
|
*
|
|
|
|
|
* @return {boolean}
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
_lte(value, key, result) {
|
|
|
|
|
let isValid = false
|
|
|
|
|
|
|
|
|
|
if (result[key] >= value) {
|
|
|
|
|
isValid = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return isValid
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* if result with key is greater
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param {object} value
|
|
|
|
|
* @param {string} key
|
|
|
|
|
* @param {object} result
|
|
|
|
|
*
|
|
|
|
|
* @return {boolean}
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
_gt(value, key, result) {
|
|
|
|
|
let isValid = false
|
|
|
|
|
|
|
|
|
|
if (result[key] < value) {
|
|
|
|
|
isValid = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return isValid
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* if result with key is greater or equal
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param {object} value
|
|
|
|
|
* @param {string} key
|
|
|
|
|
* @param {object} result
|
|
|
|
|
*
|
|
|
|
|
* @return {boolean}
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
_gte(value, key, result) {
|
|
|
|
|
let isValid = false
|
|
|
|
|
|
|
|
|
|
if (result[key] <= value) {
|
|
|
|
|
isValid = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return isValid
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* if result with key is null
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param {object} value
|
|
|
|
|
* @param {string} key
|
|
|
|
|
* @param {object} result
|
|
|
|
|
*
|
|
|
|
|
* @return {boolean}
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
_null(value, key, result) {
|
|
|
|
|
let isValid = false
|
|
|
|
|
|
|
|
|
|
if (!result[key]) {
|
|
|
|
|
isValid = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return isValid
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* if result with key is not null
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param {object} value
|
|
|
|
|
* @param {string} key
|
|
|
|
|
* @param {object} result
|
|
|
|
|
*
|
|
|
|
|
* @return {boolean}
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
_nnull(value, key, result) {
|
|
|
|
|
let isValid = false
|
|
|
|
|
|
|
|
|
|
if (result[key]) {
|
|
|
|
|
isValid = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return isValid
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* run through all options with single result
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param {object} result
|
|
|
|
|
* @return {boolean}
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
validate(result) {
|
|
|
|
|