aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/helpers/custom-validators/search.ts
blob: bb17134c391926a14f775d88a0a542df34b7d5f5 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
                                 









                                                                    



                                                                  



                                                                              

                  
 
import 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
}