Skip to content

Commit

Permalink
refuse additional chars in names (#17086)
Browse files Browse the repository at this point in the history
  • Loading branch information
batemapf authored May 5, 2021
1 parent c0f43ee commit c3ca27e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { personalInformation } from '../schema-imports';
import currentOrPastDateUI from 'platform/forms-system/src/js/definitions/currentOrPastDate';

function containsDisallowedCharacters(value) {
const disAllowedCharacters = ['(', ')'];
const disAllowedCharacters = ['(', ')', ',', ':', ';'];
for (const character of disAllowedCharacters) {
if (value.indexOf(character) !== -1) {
return true;
Expand All @@ -28,7 +28,9 @@ export const uiSchema = {
function(errors, fieldData) {
const setError = containsDisallowedCharacters(fieldData);
if (setError) {
errors.addError('Please only use letters and no parentheses');
errors.addError(
'Please only use letters and no special punctuation',
);
}
},
],
Expand All @@ -46,7 +48,7 @@ export const uiSchema = {
const setError = containsDisallowedCharacters(fieldData);
if (setError) {
errors.addError(
'Please only use your current last name and no parentheses',
'Please only use your current last name and no special punctuation',
);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,17 @@ describe('COVID-19 SAVE LIVES Act sign up', () => {
cy.findByLabelText(/Middle name/i).focus();

cy.get('#root_firstName-error-message').contains(
'Please only use letters and no parentheses',
'Error Please only use letters and no special punctuation',
);

cy.findByLabelText(/First name/i)
.clear()
.type('Stephen:');

cy.findByLabelText(/Middle name/i).focus();

cy.get('#root_firstName-error-message').contains(
'Error Please only use letters and no special punctuation',
);

cy.findByLabelText(/Last name/i)
Expand All @@ -41,7 +51,17 @@ describe('COVID-19 SAVE LIVES Act sign up', () => {
cy.findByLabelText(/Middle name/i).focus();

cy.get('#root_lastName-error-message').contains(
'Error Please only use your current last name and no parentheses',
'Error Please only use your current last name and no special punctuation',
);

cy.findByLabelText(/Last name/i)
.clear()
.type('Beers,');

cy.findByLabelText(/Middle name/i).focus();

cy.get('#root_lastName-error-message').contains(
'Error Please only use your current last name and no special punctuation',
);
});
});
Expand Down

0 comments on commit c3ca27e

Please sign in to comment.