diff options
Diffstat (limited to 'server/helpers/custom-validators/search.ts')
-rw-r--r-- | server/helpers/custom-validators/search.ts | 37 |
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 @@ | |||
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' | ||
5 | |||
6 | function isNumberArray (value: any) { | ||
7 | return isArray(value) && value.every(v => validator.isInt('' + v)) | ||
8 | } | ||
9 | |||
10 | function isStringArray (value: any) { | ||
11 | return isArray(value) && value.every(v => typeof v === 'string') | ||
12 | } | ||
13 | |||
14 | function isBooleanBothQueryValid (value: any) { | ||
15 | return value === 'true' || value === 'false' || value === 'both' | ||
16 | } | ||
17 | |||
18 | function 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 | |||
32 | export { | ||
33 | isNumberArray, | ||
34 | isStringArray, | ||
35 | isBooleanBothQueryValid, | ||
36 | isSearchTargetValid | ||
37 | } | ||