<commit_before>'use strict'

const validator = require('validator')

const constants = require('../initializers/constants')

const 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) &&
      !isNaN(val.duration) &&
      val.duration >= 0 &&
      val.duration < constants.MAXIMUM_VIDEO_DURATION &&
      validator.isLength(val.author, 1, constants.MAXIMUM_AUTHOR_LENGTH) &&
      validator.isDate(val.createdDate)
  })
}

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

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

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

module.exports = customValidators
<commit_msg>Add check for the thumbnail in base64 (requests inter pods)<commit_after>'use strict'

const validator = require('validator')

const constants = require('../initializers/constants')

const 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) &&
      !isNaN(val.duration) &&
      val.duration >= 0 &&
      val.duration < constants.MAXIMUM_VIDEO_DURATION &&
      validator.isLength(val.author, 1, constants.MAXIMUM_AUTHOR_LENGTH) &&
      validator.isBase64(val.thumbnailBase64) &&
      validator.isByteLength(val.thumbnailBase64, { min: 0, max: 20000 }) &&
      validator.isDate(val.createdDate)
  })
}

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

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

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

module.exports = customValidators

{'fraction_non_alphanumeric': 0.16993464052287582, 'fraction_numerical': 0.015522875816993464, 'mean_word_length': 3.2665505226480835, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6700153', 'n_tokens_mistral': 788, 'n_tokens_neox': 748, 'n_words': 129}