Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x |
import { daoMethodsWithReadWrite } from '../../types/core.types'
import { DaoHookNamesMongo, MongoDao } from '../mongo/types/mongoDbTypes'
export const hookValidators: Record<DaoHookNamesMongo, HookValidator> = {
//----------------------------------------
// GENERICS
//----------------------------------------
expose: {
validate: hook => {
return Array.isArray(hook.expose) && hook.expose.every(method => daoMethodsWithReadWrite.includes(method))
},
errMsg: `Check expose hook is an array an contains only values in ${daoMethodsWithReadWrite.join(', ')}`
},
mask: {
validate: (hook: MongoDao<any>['mask'][number]) => {
return typeof hook.mask === 'function' || typeof hook.select === 'function'
},
errMsg: `Check mask hook .mask OR .select is a function`
},
//----------------------------------------
// MONGO
//----------------------------------------
filter: {
validate: (hook: MongoDao<any>['filter'][number]) => {
return typeof hook.filter === 'function'
},
errMsg: `TODO`
},
}
export type HookValidator = {
validate(hook): boolean
errMsg?: string
}
|