diff --git a/packages/gafl-webapp-service/src/locales/cy.json b/packages/gafl-webapp-service/src/locales/cy.json index 5e0cda17db..4b8a737a9a 100644 --- a/packages/gafl-webapp-service/src/locales/cy.json +++ b/packages/gafl-webapp-service/src/locales/cy.json @@ -145,14 +145,15 @@ "cancel_rp_identify_body": "Ni fydd canslo eich cytundeb taliad cerdyn rheolaidd yn canslo nac yn ad-dalu eich trwydded gyfredol. Gallwch barhau i bysgota tan fydd eich trwydded gyfredol yn dod i ben ond ni fydd eich trwydded yn adnewyddu'n awtomatig.", "cancel_rp_identify_ref_number": "Chwe nodyn olaf eich trwydded", "cancel_rp_identify_ref_number_hint": "Er enghraifft, F4A315", - "cancel_rp_identify_ref_number_error": "Enter the last 6 characters of your licence number", - "cancel_rp_identify_ref_pattern": "The last six characters of your licence number don’t look right. Check and enter again", + "cancel_rp_identify_ref_number_error": "Rhowch chwe nodyn olaf eich trwydded", + "cancel_rp_identify_ref_pattern": "Nid yw chwe nodyn olaf eich trwydded yn edrych yn gywir. Gwiriwch a rhowch gynnig arall arni", "cancel_rp_identify_dob": "Dyddiad geni", "cancel_rp_identify_dob_hint": "Er enghraifft, 31 3 1980", "cancel_rp_identify_postcode": "Cod post", "cancel_rp_identify_postcode_hint": "Er enghraifft, WA4 1AB", - "cancel_rp_identify_postcode_error": "Enter a postcode", - "cancel_rp_identify_postcode_pattern": "Your postcode doesn’t look right. Check and enter again", + "cancel_rp_identify_postcode_error": "Nodwch god post", + "cancel_rp_identify_postcode_error_empty": "Nid ydych wedi nodi cod post", + "cancel_rp_identify_postcode_pattern": "Nid yw’r cod post yn edrych yn gywir. Gwiriwch a rhowch gynnig arall arni", "change_licence_details_you": "Adolygu neu newid manylion eich trwydded", "change_licence_details_other": "Adolygu neu newid manylion y drwydded", "change_licence_number": "Newid rhif y drwydded", @@ -350,7 +351,7 @@ "identify_error_missing_month": "Mae’n rhaid i’r dyddiad geni gynnwys mis", "identify_error_missing_year": "Mae’n rhaid i’r dyddiad geni gynnwys blwyddyn", "identify_error_non_numeric": "Rhowch rifau yn unig", - "identify_error_pattern_postcode": "Your postcode doesn’t look right. Check and enter again", + "identify_error_pattern_postcode": "Nid yw’r cod post yn edrych yn gywir. Gwiriwch a rhowch gynnig arall arni", "identify_error_pattern": "Nid yw chwe nodyn olaf eich trwydded yn edrych yn gywir. Gwiriwch a rhowch gynnig arall arni", "identify_error_year_min": "Mae’r dyddiad geni yn rhy bell yn ôl", "identify_error_year_max": "Mae'n rhaid i’r dyddiad geni fod yn y gorffennol", diff --git a/packages/gafl-webapp-service/src/locales/en.json b/packages/gafl-webapp-service/src/locales/en.json index 9065dff5eb..f2bab35bf9 100644 --- a/packages/gafl-webapp-service/src/locales/en.json +++ b/packages/gafl-webapp-service/src/locales/en.json @@ -152,6 +152,7 @@ "cancel_rp_identify_postcode": "Postcode", "cancel_rp_identify_postcode_hint": "For example, WA4 1AB", "cancel_rp_identify_postcode_error": "Enter a postcode", + "cancel_rp_identify_postcode_error_empty": "You did not enter a postcode", "cancel_rp_identify_postcode_pattern": "Your postcode doesn’t look right. Check and enter again", "change_licence_details_you": "Review or change the licence details", "change_licence_details_other": "Review or change the licence details", diff --git a/packages/gafl-webapp-service/src/pages/recurring-payments/cancel/identify/cancel-rp-identify.njk b/packages/gafl-webapp-service/src/pages/recurring-payments/cancel/identify/cancel-rp-identify.njk index 919a096706..db7c9608ac 100644 --- a/packages/gafl-webapp-service/src/pages/recurring-payments/cancel/identify/cancel-rp-identify.njk +++ b/packages/gafl-webapp-service/src/pages/recurring-payments/cancel/identify/cancel-rp-identify.njk @@ -18,7 +18,7 @@ 'string.pattern.base': { text: mssgs.cancel_rp_identify_ref_pattern, ref: '#ref' } }, 'postcode': { - 'string.empty': { ref: '#postcode', text: mssgs.cancel_rp_identify_postcode_error }, + 'string.empty': { ref: '#postcode', text: mssgs.cancel_rp_identify_postcode_error_empty }, 'string.pattern.base': { ref: '#postcode', text: mssgs.cancel_rp_identify_postcode_pattern } }, 'full-date': { diff --git a/packages/gafl-webapp-service/src/pages/recurring-payments/cancel/identify/route.js b/packages/gafl-webapp-service/src/pages/recurring-payments/cancel/identify/route.js index bf33fcf32a..4eecf3b60d 100644 --- a/packages/gafl-webapp-service/src/pages/recurring-payments/cancel/identify/route.js +++ b/packages/gafl-webapp-service/src/pages/recurring-payments/cancel/identify/route.js @@ -5,6 +5,7 @@ import { validation } from '@defra-fish/business-rules-lib' import { addLanguageCodeToUri } from '../../../../processors/uri-helper.js' import GetDataRedirect from '../../../../handlers/get-data-redirect.js' import { dateOfBirthValidator, getDateErrorFlags } from '../../../../schema/validators/validators.js' +import { runValidators } from '../../../../utils/validators.js' export const getData = async request => { const permission = await request.cache().helpers.transaction.getCurrentPermission() @@ -35,17 +36,22 @@ export const getData = async request => { } export const validator = payload => { - dateOfBirthValidator(payload) - - Joi.assert( - { - postcode: payload.postcode, - referenceNumber: payload.referenceNumber - }, - Joi.object({ - referenceNumber: validation.permission.permissionNumberUniqueComponentValidator(Joi), - postcode: validation.contact.createOverseasPostcodeValidator(Joi) - }).options({ abortEarly: false }) + runValidators( + [ + p => + Joi.assert( + { + postcode: p.postcode, + referenceNumber: p.referenceNumber + }, + Joi.object({ + referenceNumber: validation.permission.permissionNumberUniqueComponentValidator(Joi), + postcode: validation.contact.createOverseasPostcodeValidator(Joi) + }).options({ abortEarly: false }) + ), + dateOfBirthValidator + ], + payload ) }