Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PP-12237 Fix permissive regex #4190

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/utils/validation/server-side-form-validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function validatePostcode (postcode, countryCode) {
return validReturnObject
}

if (!/^[A-z0-9 ]+$/.test(postcode)) {
if (!/^[A-Za-z0-9 ]+$/.test(postcode)) {
return notValidReturnObject('Enter a real postcode')
}

Expand Down
7 changes: 7 additions & 0 deletions app/utils/validation/server-side-form-validations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ describe('Server side form validations', () => {
})
})

it('should not be valid when postcode is UK postcode with ^ character', () => {
expect(validations.validatePostcode('NW1^ 5GH')).to.deep.equal({
valid: false,
message: 'Enter a real postcode'
})
})

it('should not be valid when postcode is not UK postcode and country not provided', () => {
expect(validations.validatePostcode('CA90210')).to.deep.equal({
valid: false,
Expand Down
Loading