Skip to content

Commit b0508e9

Browse files
committed
fix: allow startDate be same as endDate for RB
1 parent 028bd2f commit b0508e9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/services/ResourceBookingService.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ createResourceBooking.schema = Joi.object().keys({
165165
startDate: Joi.date().allow(null),
166166
endDate: Joi.date().when('startDate', {
167167
is: Joi.exist(),
168-
then: Joi.date().allow(null).greater(Joi.ref('startDate')
168+
then: Joi.date().allow(null).min(Joi.ref('startDate')
169169
).messages({
170-
'date.greater': 'endDate must be greater than startDate'
170+
'date.min': 'endDate cannot be earlier than startDate'
171171
}),
172172
otherwise: Joi.date().allow(null)
173173
}),
@@ -222,9 +222,9 @@ partiallyUpdateResourceBooking.schema = Joi.object().keys({
222222
startDate: Joi.date().allow(null),
223223
endDate: Joi.date().when('startDate', {
224224
is: Joi.exist(),
225-
then: Joi.date().allow(null).greater(Joi.ref('startDate')
225+
then: Joi.date().allow(null).min(Joi.ref('startDate')
226226
).messages({
227-
'date.greater': 'endDate must be greater than startDate'
227+
'date.min': 'endDate cannot be earlier than startDate'
228228
}),
229229
otherwise: Joi.date().allow(null)
230230
}),
@@ -259,9 +259,9 @@ fullyUpdateResourceBooking.schema = Joi.object().keys({
259259
startDate: Joi.date().allow(null).default(null),
260260
endDate: Joi.date().when('startDate', {
261261
is: Joi.exist(),
262-
then: Joi.date().allow(null).default(null).greater(Joi.ref('startDate')
262+
then: Joi.date().allow(null).default(null).min(Joi.ref('startDate')
263263
).messages({
264-
'date.greater': 'endDate must be greater than startDate'
264+
'date.min': 'endDate cannot be earlier than startDate'
265265
}),
266266
otherwise: Joi.date().allow(null).default(null)
267267
}),

0 commit comments

Comments
 (0)