aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/runners/runners.ts
blob: 953fac3b5dc2ed5285c794c62a1935bf26599ce5 (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
28
29
30
import validator from 'validator'
import { CONSTRAINTS_FIELDS } from '@server/initializers/constants'
import { exists } from '../misc'

const RUNNERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.RUNNERS

function isRunnerRegistrationTokenValid (value: string) {
  return exists(value) && validator.isLength(value, RUNNERS_CONSTRAINTS_FIELDS.TOKEN)
}

function isRunnerTokenValid (value: string) {
  return exists(value) && validator.isLength(value, RUNNERS_CONSTRAINTS_FIELDS.TOKEN)
}

function isRunnerNameValid (value: string) {
  return exists(value) && validator.isLength(value, RUNNERS_CONSTRAINTS_FIELDS.NAME)
}

function isRunnerDescriptionValid (value: string) {
  return exists(value) && validator.isLength(value, RUNNERS_CONSTRAINTS_FIELDS.DESCRIPTION)
}

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

export {
  isRunnerRegistrationTokenValid,
  isRunnerTokenValid,
  isRunnerNameValid,
  isRunnerDescriptionValid
}