Skip to content

Commit 9d1fc6f

Browse files
committed
#4039 move logic to validation util
1 parent 70e473a commit 9d1fc6f

2 files changed

Lines changed: 1 addition & 6 deletions

File tree

src/backend/src/services/calendar.services.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,6 @@ export default class CalendarService {
271271
zoomLink?: string,
272272
description?: string
273273
): Promise<Event> {
274-
if (!title.trim()) throw new HttpException(400, 'Title cannot be only whitespace');
275-
276274
// Validate eventTypeId
277275
const foundEventType = await prisma.event_Type.findUnique({
278276
where: { eventTypeId }
@@ -594,8 +592,6 @@ export default class CalendarService {
594592
zoomLink?: string,
595593
description?: string
596594
): Promise<Event> {
597-
if (!title.trim()) throw new HttpException(400, 'Title cannot be only whitespace');
598-
599595
// validate eventId
600596
const foundEvent = await prisma.event.findUnique({
601597
where: { eventId },

src/backend/src/utils/validation.utils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ export const decimalMinZero = (validationObject: ValidationChain): ValidationCha
2323
.withMessage('Value must be greater than or equal to zero');
2424
};
2525

26-
//Const to return if an input is a string and is not empty
2726
export const nonEmptyString = (validationObject: ValidationChain): ValidationChain => {
28-
return validationObject.isString().not().isEmpty();
27+
return validationObject.isString().not().isEmpty({ ignore_whitespace: true });
2928
};
3029

3130
export const isRole = (validationObject: ValidationChain): ValidationChain => {

0 commit comments

Comments
 (0)