aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/helpers/customValidators.js
blob: 20c41f5da3d4af555d9a545eea3873f8cc66f5be (plain) (tree)
1
2
3
4
5
6
7
8
9
            
 
                                    
 




                                                               
 







                                                   
 




                                                 
 


                             
 
                                                                              
 
                                 
'use strict'

var validator = require('validator')

var customValidators = {
  eachIsRemoteVideosAddValid: eachIsRemoteVideosAddValid,
  eachIsRemoteVideosRemoveValid: eachIsRemoteVideosRemoveValid,
  isArray: isArray
}

function eachIsRemoteVideosAddValid (values) {
  return values.every(function (val) {
    return validator.isLength(val.name, 1, 50) &&
      validator.isLength(val.description, 1, 50) &&
      validator.isLength(val.magnetUri, 10) &&
      validator.isURL(val.podUrl)
  })
}

function eachIsRemoteVideosRemoveValid (values) {
  return values.every(function (val) {
    return validator.isLength(val.magnetUri, 10)
  })
}

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

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

module.exports = customValidators