aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/misc.js
blob: 13904ea1b1faa5d1c1998be0e539942bda5704cf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict'

const validator = require('express-validator').validator

const miscValidators = {
  exists: exists,
  isArray: isArray,
  isEachUrl: isEachUrl
}

function exists (value) {
  return value !== undefined && value !== null
}

function isArray (value) {
  return Array.isArray(value)
}

function isEachUrl (urls) {
  return urls.every(function (url) {
    return validator.isURL(url)
  })
}

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

module.exports = miscValidators