search.ts 574 B

123456789101112131415161718192021222324
  1. import * as validator from 'validator'
  2. import 'express-validator'
  3. import { isArray } from './misc'
  4. function isNumberArray (value: any) {
  5. return isArray(value) && value.every(v => validator.isInt('' + v))
  6. }
  7. function isStringArray (value: any) {
  8. return isArray(value) && value.every(v => typeof v === 'string')
  9. }
  10. function isNSFWQueryValid (value: any) {
  11. return value === 'true' || value === 'false' || value === 'both'
  12. }
  13. // ---------------------------------------------------------------------------
  14. export {
  15. isNumberArray,
  16. isStringArray,
  17. isNSFWQueryValid
  18. }