mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-12 02:43:50 +00:00
refactor: lax validation for settings
with this changes we allow the client and server to share the same data shape. even if some of it is useless. we also get an extra version property in the payload, if we want to save the transfer cost, we would rather remove it from the sent payload
This commit is contained in:
committed by
Alex Christoffer Rasmussen
parent
1866e5e78d
commit
48b9cf042f
@@ -1,4 +1,4 @@
|
||||
import { body, checkExact } from 'express-validator';
|
||||
import { body } from 'express-validator';
|
||||
import { requestValidationFunction } from '../validation-utils/validationFunction.js';
|
||||
|
||||
/**
|
||||
@@ -8,11 +8,10 @@ export const validateWelcomeDialog = [body('show').isBoolean(), requestValidatio
|
||||
|
||||
const pinValidator = (key: string) => {
|
||||
return body(key)
|
||||
.isString()
|
||||
.trim()
|
||||
.optional()
|
||||
.isLength({ min: 0, max: 4 })
|
||||
.customSanitizer((input) => {
|
||||
if (input.length === 0) {
|
||||
if (input === null || input.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return input;
|
||||
@@ -28,8 +27,6 @@ export const validateSettings = [
|
||||
body('timeFormat').isString().isIn(['12', '24']).withMessage('Time format can only be "12" or "24"'),
|
||||
body('language').isString().trim().notEmpty(),
|
||||
body('serverPort').isPort().withMessage('Invalid value found for server port').toInt(),
|
||||
checkExact(),
|
||||
|
||||
requestValidationFunction,
|
||||
];
|
||||
// TODO: dont allow other keys
|
||||
|
||||
Reference in New Issue
Block a user