1 import validator from 'validator'
2 import { SearchTargetType } from '@shared/models/search/search-target-query.model'
3 import { isArray, exists } from './misc'
4 import { CONFIG } from '@server/initializers/config'
6 function isNumberArray (value: any) {
7 return isArray(value) && value.every(v => validator.isInt('' + v))
10 function isStringArray (value: any) {
11 return isArray(value) && value.every(v => typeof v === 'string')
14 function isBooleanBothQueryValid (value: any) {
15 return value === 'true' || value === 'false' || value === 'both'
18 function isSearchTargetValid (value: SearchTargetType) {
19 if (!exists(value)) return true
21 const searchIndexConfig = CONFIG.SEARCH.SEARCH_INDEX
23 if (value === 'local' && (!searchIndexConfig.ENABLED || !searchIndexConfig.DISABLE_LOCAL_SEARCH)) return true
25 if (value === 'search-index' && searchIndexConfig.ENABLED) return true
30 // ---------------------------------------------------------------------------
35 isBooleanBothQueryValid,