Skip to content

Commit

Permalink
Merge pull request #1463 from govuk-one-login/BUG/reorder-validation-…
Browse files Browse the repository at this point in the history
…messages-on-create-password

AUT-2612: Reorder validation messages on create password screen
  • Loading branch information
gtvj authored Mar 27, 2024
2 parents 0ccc9d0 + 7a307ca commit 1207e5d
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/components/create-password/create-password-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down Expand Up @@ -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"),
];
}

0 comments on commit 1207e5d

Please sign in to comment.