]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
improve api param message for dates
authorRigel Kent <sendmemail@rigelk.eu>
Mon, 31 May 2021 17:47:14 +0000 (19:47 +0200)
committerRigel Kent <sendmemail@rigelk.eu>
Mon, 31 May 2021 17:47:24 +0000 (19:47 +0200)
server/middlewares/validators/activitypub/signature.ts
server/middlewares/validators/logs.ts
server/middlewares/validators/search.ts
server/middlewares/validators/user-history.ts
server/middlewares/validators/videos/videos.ts

index 7c4e4946329d12e330bd070693bac2f4862e6e66..7896a612806aed568c3e3b05900679388f1a7f5a 100644 (file)
@@ -14,7 +14,7 @@ const signatureValidator = [
     .custom(isSignatureTypeValid).withMessage('Should have a valid signature type'),
   body('signature.created')
     .optional()
-    .custom(isDateValid).withMessage('Should have a valid signature created date'),
+    .custom(isDateValid).withMessage('Should have a signature created date that conforms to ISO 8601'),
   body('signature.creator')
     .optional()
     .custom(isSignatureCreatorValid).withMessage('Should have a valid signature creator'),
index 70e4d0d99de196caf5af73910c9a905ecd7c901a..ba817d9a9e19a418d297511883be3119aa29977a 100644 (file)
@@ -7,13 +7,13 @@ import { isValidLogLevel } from '../../helpers/custom-validators/logs'
 
 const getLogsValidator = [
   query('startDate')
-    .custom(isDateValid).withMessage('Should have a valid start date'),
+    .custom(isDateValid).withMessage('Should have a start date that conforms to ISO 8601'),
   query('level')
     .optional()
     .custom(isValidLogLevel).withMessage('Should have a valid level'),
   query('endDate')
     .optional()
-    .custom(isDateValid).withMessage('Should have a valid end date'),
+    .custom(isDateValid).withMessage('Should have an end date that conforms to ISO 8601'),
 
   (req: express.Request, res: express.Response, next: express.NextFunction) => {
     logger.debug('Checking getLogsValidator parameters.', { parameters: req.query })
@@ -26,10 +26,10 @@ const getLogsValidator = [
 
 const getAuditLogsValidator = [
   query('startDate')
-    .custom(isDateValid).withMessage('Should have a valid start date'),
+    .custom(isDateValid).withMessage('Should have a start date that conforms to ISO 8601'),
   query('endDate')
     .optional()
-    .custom(isDateValid).withMessage('Should have a valid end date'),
+    .custom(isDateValid).withMessage('Should have a end date that conforms to ISO 8601'),
 
   (req: express.Request, res: express.Response, next: express.NextFunction) => {
     logger.debug('Checking getAuditLogsValidator parameters.', { parameters: req.query })
index 78213c70da16a02a163f63eb85489c541c5915bc..d2f5277502378044d4ed5bdeb4fcab6acfd53a09 100644 (file)
@@ -8,11 +8,19 @@ import { isSearchTargetValid } from '@server/helpers/custom-validators/search'
 const videosSearchValidator = [
   query('search').optional().not().isEmpty().withMessage('Should have a valid search'),
 
-  query('startDate').optional().custom(isDateValid).withMessage('Should have a valid start date'),
-  query('endDate').optional().custom(isDateValid).withMessage('Should have a valid end date'),
-
-  query('originallyPublishedStartDate').optional().custom(isDateValid).withMessage('Should have a valid published start date'),
-  query('originallyPublishedEndDate').optional().custom(isDateValid).withMessage('Should have a valid published end date'),
+  query('startDate')
+    .optional()
+    .custom(isDateValid).withMessage('Should have a start date that conforms to ISO 8601'),
+  query('endDate')
+    .optional()
+    .custom(isDateValid).withMessage('Should have a end date that conforms to ISO 8601'),
+
+  query('originallyPublishedStartDate')
+    .optional()
+    .custom(isDateValid).withMessage('Should have a published start date that conforms to ISO 8601'),
+  query('originallyPublishedEndDate')
+    .optional()
+    .custom(isDateValid).withMessage('Should have a published end date that conforms to ISO 8601'),
 
   query('durationMin').optional().isInt().withMessage('Should have a valid min duration'),
   query('durationMax').optional().isInt().withMessage('Should have a valid max duration'),
index 058bf77583a9c27c6ceb5ba096bc039b68332474..647294cc38cd7ebaca08f39a1b2d5620fe9c0222 100644 (file)
@@ -21,7 +21,7 @@ const userHistoryListValidator = [
 const userHistoryRemoveValidator = [
   body('beforeDate')
     .optional()
-    .custom(isDateValid).withMessage('Should have a valid before date'),
+    .custom(isDateValid).withMessage('Should have a before date that conforms to ISO 8601'),
 
   (req: express.Request, res: express.Response, next: express.NextFunction) => {
     logger.debug('Checking userHistoryRemoveValidator parameters', { parameters: req.body })
index 3219e10d4fbbd7913f7daa706f67a306378e6e5a..dce02df18adcd46ea6c6f5cfca167ba045b65923 100644 (file)
@@ -473,7 +473,7 @@ function getCommonVideoEditAttributes () {
       .customSanitizer(toValueOrNull),
     body('scheduleUpdate.updateAt')
       .optional()
-      .custom(isDateValid).withMessage('Should have a valid schedule update date'),
+      .custom(isDateValid).withMessage('Should have a schedule update date that conforms to ISO 8601'),
     body('scheduleUpdate.privacy')
       .optional()
       .customSanitizer(toIntOrNull)