mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-10 18:03:47 +00:00
1849b4d39f
* chore: migrate eslint to oxlint * chore: migrate prettier to oxfmt * chore: migrate typescript * chore: toThrow should have a expected value * chore: cast test value as Day * chore: small title fix * chore: mocks should be hoisted * chore: incorrect async useage * chore: test should be inside description * chore: test sohuld include an expeced * chore: oxfmt --------- Co-authored-by: alex-Arc <omnivox@LAPTOP-RC5SNBVV.localdomain>
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import { body, param } from 'express-validator';
|
|
import { OntimeView } from 'ontime-types';
|
|
|
|
import { requestValidationFunction } from '../validation-utils/validationFunction.js';
|
|
|
|
/**
|
|
* validate array of URL preset objects
|
|
*/
|
|
export const validateNewPreset = [
|
|
body().isObject().withMessage('No data found in request'),
|
|
body('enabled').isBoolean(),
|
|
body('alias').isString().trim().notEmpty(),
|
|
body('target').isString().trim().notEmpty().isIn(Object.values(OntimeView)),
|
|
body('search').isString().trim(),
|
|
|
|
// options are currently only provided for cuesheet presets
|
|
body('options').optional().isObject(),
|
|
body('options.*').isString().trim(),
|
|
|
|
requestValidationFunction,
|
|
];
|
|
|
|
export const validateUpdatePreset = [
|
|
param('alias').isString().trim().notEmpty(),
|
|
body().isObject().withMessage('No data found in request'),
|
|
body('enabled').isBoolean(),
|
|
body('alias').isString().trim().notEmpty(),
|
|
body('target').isString().trim().notEmpty().isIn(Object.values(OntimeView)),
|
|
body('search').isString().trim(),
|
|
|
|
// options are currently only provided for cuesheet presets
|
|
body('options').optional().isObject(),
|
|
body('options.*').isString().trim(),
|
|
|
|
requestValidationFunction,
|
|
];
|
|
|
|
export const validatePresetParam = [param('alias').isString().trim().notEmpty(), requestValidationFunction];
|