aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/search.ts
blob: ee732b15aa1f83b0a1253249d65a02f52e2b045d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import * as validator from 'validator'
import { isArray } from './misc'

function isNumberArray (value: any) {
  return isArray(value) && value.every(v => validator.isInt('' + v))
}

function isStringArray (value: any) {
  return isArray(value) && value.every(v => typeof v === 'string')
}

function isNSFWQueryValid (value: any) {
  return value === 'true' || value === 'false' || value === 'both'
}

// ---------------------------------------------------------------------------

export {
  isNumberArray,
  isStringArray,
  isNSFWQueryValid
}