Skip to content

Commit

Permalink
PAF-128 & PAF-129 Added validation for phone and country textbox
Browse files Browse the repository at this point in the history
[PAF- 129](https://collaboration.homeoffice.gov.uk/jira/browse/PAF-129) All 'Country' fields allow any text without the use of drop down list

[PAF-128](https://collaboration.homeoffice.gov.uk/jira/browse/PAF-128 URL's are being accepted in all free text fields

- added validation rules to all countries fields in field/index.js

- added dependent property to avoid error message when yes  is selected on another location

Tested manually
  • Loading branch information
TemitopeAyokuHO committed Jan 18, 2024
1 parent 3d96efa commit c52738a
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 6 deletions.
27 changes: 21 additions & 6 deletions apps/paf/fields/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ module.exports = {
'boat-country-departure': {
mixin: 'select',
className: ['typeahead', 'js-hidden'],
validate: ['required', 'notUrl'],
options:
[{
value: '',
Expand Down Expand Up @@ -402,6 +403,7 @@ module.exports = {
'train-country-departure': {
mixin: 'select',
className: ['typeahead', 'js-hidden'],
validate: ['required', 'notUrl'],
options:
[{
value: '',
Expand Down Expand Up @@ -439,6 +441,7 @@ module.exports = {
'airline-country-departure': {
mixin: 'select',
className: ['typeahead', 'js-hidden'],
validate: ['required', 'notUrl'],
options:
[{
value: '',
Expand Down Expand Up @@ -531,6 +534,7 @@ module.exports = {
'crime-location-country': {
mixin: 'select',
className: ['typeahead', 'js-hidden'],
validate: ['required', 'notUrl'],
options:
[{
value: '',
Expand Down Expand Up @@ -578,7 +582,11 @@ module.exports = {
},
'crime-location-phone': {
className: ['govuk-input', 'govuk-input--width-20'],
validate: [{ type: 'maxlength', arguments: 20 }]
validate: ['required', { type: 'maxlength', arguments: 20 }],
dependent: {
field: 'crime-location',
value: 'yes'
}
},
'crime-another-location': {
isPageHeading: true,
Expand All @@ -594,6 +602,7 @@ module.exports = {
'crime-another-location-country': {
mixin: 'select',
className: ['typeahead', 'js-hidden'],
validate: ['required', 'notUrl'],
options:
[{
value: '',
Expand Down Expand Up @@ -641,7 +650,11 @@ module.exports = {
},
'crime-another-location-phone': {
className: ['govuk-input', 'govuk-input--width-20'],
validate: [{ type: 'maxlength', arguments: 20 }]
validate: ['required', { type: 'maxlength', arguments: 20 }],
dependent: {
field: 'crime-another-location',
value: 'yes'
}
},
'report-person': {
mixin: 'radio-group',
Expand Down Expand Up @@ -742,6 +755,7 @@ module.exports = {
'report-person-location-outside-uk-address-country': {
mixin: 'select',
className: ['typeahead', 'js-hidden'],
validate: ['required', 'notUrl'],
options:
[{
value: '',
Expand All @@ -768,6 +782,7 @@ module.exports = {
'report-person-location-travel-to-uk-country': {
mixin: 'select',
className: ['typeahead', 'js-hidden'],
validate: ['required', 'notUrl'],
options:
[{
value: '',
Expand All @@ -789,7 +804,7 @@ module.exports = {
},
'report-person-location-phone': {
className: ['govuk-input', 'govuk-input--width-20'],
validate: [{ type: 'maxlength', arguments: 20 }]
validate: ['required', { type: 'maxlength', arguments: 20 }]
},
'report-person-location-email': {
validate: ['email', { type: 'maxlength', arguments: 100 }]
Expand Down Expand Up @@ -873,7 +888,7 @@ module.exports = {
},
'report-person-occupation-company-phone': {
className: ['govuk-input', 'govuk-input--width-20'],
validate: [{ type: 'maxlength', arguments: 20 }]
validate: ['required', { type: 'maxlength', arguments: 20 }]
},
'report-person-occupation-company-manager': {
mixin: 'input-text',
Expand Down Expand Up @@ -933,7 +948,7 @@ module.exports = {
},
'report-person-study-phone': {
className: ['govuk-input', 'govuk-input--width-20'],
validate: [{ type: 'maxlength', arguments: 20 }]
validate: ['required', { type: 'maxlength', arguments: 20 }]
},
'report-person-study-email': {
validate: ['email', { type: 'maxlength', arguments: 100 }]
Expand Down Expand Up @@ -1189,7 +1204,7 @@ module.exports = {
},
'company-phone': {
className: ['govuk-input', 'govuk-input--width-20'],
validate: [{ type: 'maxlength', arguments: 20 }]
validate: ['required', { type: 'maxlength', arguments: 20 }]
},
'company-email': {
formatter: ['removespaces'],
Expand Down
41 changes: 41 additions & 0 deletions apps/paf/translations/src/en/validation.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,19 @@
"maxlength": "You can't use more than {{maxlength}} characters for your answer"
},
"crime-location-phone": {
"required": "Enter a valid phone number",
"maxlength": "You can't use more than {{maxlength}} characters for your answer"
},

"report-person-study-phone": {
"required": "Enter a valid phone number",
"maxlength": "You can't use more than {{maxlength}} characters for your answer"
},
"crime-another-location-address-postcode": {
"maxlength": "You can't use more than {{maxlength}} characters for your answer"
},
"crime-another-location-phone": {
"required": "Enter a valid phone number",
"maxlength": "You can't use more than {{maxlength}} numbers for your answer"
},
"report-person-first-name": {
Expand Down Expand Up @@ -130,6 +137,7 @@
"maxlength": "You can't use more than {{maxlength}} characters for your answer"
},
"report-person-location-phone": {
"required": "Enter a valid phone number",
"maxlength": "You can't use more than {{maxlength}} characters for your answer"
},
"report-person-location-email": {
Expand All @@ -156,6 +164,11 @@
"maxlength": "You can't use more than {{maxlength}} characters for your answer"
},
"report-person-occupation-company-phone": {
"required": "Enter a valid phone number",
"maxlength": "You can't use more than {{maxlength}} characters for your answer"
},
"company-phone": {
"required": "Enter a valid phone number",
"maxlength": "You can't use more than {{maxlength}} characters for your answer"
},
"report-person-occupation-company-manager": {
Expand Down Expand Up @@ -276,5 +289,33 @@
},
"when-to-contact": {
"maxlength": "You can't use more than {{maxlength}} characters for your answer"
},
"boat-country-departure": {
"required": "Enter a valid country",
"notUrl": "Enter a valid country on the list"
},
"airline-country-departure": {
"required": "Enter a valid country",
"notUrl": "Enter a valid country on the list"
},
"crime-location-country": {
"required": "Enter a valid country",
"notUrl": "Enter a valid country on the list"
},
"crime-another-location-country": {
"required": "Enter a valid country",
"notUrl": "Enter a valid country on the list"
},
"train-country-departure": {
"required": "Enter a valid country",
"notUrl": "Enter a valid country on the list"
},
"report-person-location-outside-uk-address-country": {
"required": "Enter a valid country",
"notUrl": "Enter a valid country on the list"
},
"report-person-location-travel-to-uk-country": {
"required": "Enter a valid country",
"notUrl": "Enter a valid country on the list"
}
}

0 comments on commit c52738a

Please sign in to comment.