From 7a307ca96e8ebd41bf7957c9b63260b85e800240 Mon Sep 17 00:00:00 2001 From: GTVJ Date: Tue, 19 Mar 2024 10:38:51 +0000 Subject: [PATCH] BUG: Reorder validation messages on password creation screen Fixes a bug where the message to "Re-type password" was appearing before the message to "Enter your password" --- .../create-password-validation.ts | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/components/create-password/create-password-validation.ts b/src/components/create-password/create-password-validation.ts index 9a2fab279..a3320d712 100644 --- a/src/components/create-password/create-password-validation.ts +++ b/src/components/create-password/create-password-validation.ts @@ -5,24 +5,6 @@ import { ValidationChainFunc } from "../../types"; export function validateCreatePasswordRequest(): ValidationChainFunc { return [ - body("confirm-password") - .notEmpty() - .withMessage((value, { req }) => { - return req.t( - "pages.createPassword.confirmPassword.validationError.required", - { value } - ); - }) - .custom((value, { req }) => { - if (value !== req.body["password"]) { - throw new Error( - req.t( - "pages.createPassword.confirmPassword.validationError.matches" - ) - ); - } - return true; - }), body("password") .notEmpty() .withMessage((value, { req }) => { @@ -61,6 +43,24 @@ export function validateCreatePasswordRequest(): ValidationChainFunc { } return true; }), + body("confirm-password") + .notEmpty() + .withMessage((value, { req }) => { + return req.t( + "pages.createPassword.confirmPassword.validationError.required", + { value } + ); + }) + .custom((value, { req }) => { + if (value !== req.body["password"]) { + throw new Error( + req.t( + "pages.createPassword.confirmPassword.validationError.matches" + ) + ); + } + return true; + }), validateBodyMiddleware("create-password/index.njk"), ]; }