mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-09 09:23:51 +00:00
refactor: extract regex utilities
This commit is contained in:
committed by
Carlos Valente
parent
44508ce8b4
commit
5bc286145d
@@ -1,5 +1,5 @@
|
||||
import { DatabaseModel, CustomFields, CustomField } from 'ontime-types';
|
||||
import { isAlphanumericWithSpace, customFieldLabelToKey } from 'ontime-utils';
|
||||
import { checkRegex, customFieldLabelToKey } from 'ontime-utils';
|
||||
|
||||
import type { ErrorEmitter } from '../../utils/parserUtils.js';
|
||||
|
||||
@@ -29,7 +29,7 @@ export function sanitiseCustomFields(data: object): CustomFields {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isAlphanumericWithSpace(field.label)) {
|
||||
if (!checkRegex.isAlphanumericWithSpace(field.label)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { isAlphanumericWithSpace } from 'ontime-utils';
|
||||
import { checkRegex } from 'ontime-utils';
|
||||
|
||||
import { body, param } from 'express-validator';
|
||||
import { requestValidationFunction } from '../validation-utils/validationFunction.js';
|
||||
@@ -9,7 +9,7 @@ export const validateCustomField = [
|
||||
.trim()
|
||||
.notEmpty()
|
||||
.custom((value) => {
|
||||
return isAlphanumericWithSpace(value);
|
||||
return checkRegex.isAlphanumericWithSpace(value);
|
||||
}),
|
||||
body('type').isIn(['text', 'image']),
|
||||
body('colour').isString().trim(),
|
||||
@@ -24,7 +24,7 @@ export const validateEditCustomField = [
|
||||
.trim()
|
||||
.notEmpty()
|
||||
.custom((value) => {
|
||||
return isAlphanumericWithSpace(value);
|
||||
return checkRegex.isAlphanumericWithSpace(value);
|
||||
}),
|
||||
body('type').isIn(['text', 'image']),
|
||||
body('colour').isString().trim(),
|
||||
|
||||
Reference in New Issue
Block a user