aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/search.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/custom-validators/search.ts')
-rw-r--r--server/helpers/custom-validators/search.ts37
1 files changed, 0 insertions, 37 deletions
diff --git a/server/helpers/custom-validators/search.ts b/server/helpers/custom-validators/search.ts
deleted file mode 100644
index 6dba5d14e..000000000
--- a/server/helpers/custom-validators/search.ts
+++ /dev/null
@@ -1,37 +0,0 @@
1import validator from 'validator'
2import { SearchTargetType } from '@shared/models/search/search-target-query.model'
3import { isArray, exists } from './misc'
4import { CONFIG } from '@server/initializers/config'
5
6function isNumberArray (value: any) {
7 return isArray(value) && value.every(v => validator.isInt('' + v))
8}
9
10function isStringArray (value: any) {
11 return isArray(value) && value.every(v => typeof v === 'string')
12}
13
14function isBooleanBothQueryValid (value: any) {
15 return value === 'true' || value === 'false' || value === 'both'
16}
17
18function isSearchTargetValid (value: SearchTargetType) {
19 if (!exists(value)) return true
20
21 const searchIndexConfig = CONFIG.SEARCH.SEARCH_INDEX
22
23 if (value === 'local') return true
24
25 if (value === 'search-index' && searchIndexConfig.ENABLED) return true
26
27 return false
28}
29
30// ---------------------------------------------------------------------------
31
32export {
33 isNumberArray,
34 isStringArray,
35 isBooleanBothQueryValid,
36 isSearchTargetValid
37}