Skip to content

Commit

Permalink
Merge pull request #2244 from alphagov/PP-11355-add_real_apostrophe_t…
Browse files Browse the repository at this point in the history
…o_regex

PP-11355 add real apostrophe to regex
  • Loading branch information
SandorArpa authored Nov 10, 2023
2 parents 316870d + 5b315be commit 9c596ff
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ public class ServiceRequestValidator {

public static final String SERVICE_SEARCH_SUPPORT_ERR_MSG = "Search only supports searching by service name or merchant name";
public static final String SERVICE_SEARCH_LENGTH_ERR_MSG = "Search strings can only be 60 characters or less";
public static final String SERVICE_SEARCH_SPECIAL_CHARS_ERR_MSG = "Search strings can only contain letters, numbers and spaces";
public static final String SERVICE_SEARCH_SPECIAL_CHARS_ERR_MSG = "Search strings can only contain letters, numbers, spaces, apostrophes and hyphens";

private static final int FIELD_MERCHANT_DETAILS_NAME_MAX_LENGTH = 255;
private static final int FIELD_MERCHANT_DETAILS_EMAIL_MAX_LENGTH = 255;
private static final int MAX_SEARCH_STRING_LENGTH = 60;

private static final Pattern ALLOWED_SEARCH_CHARS = Pattern.compile("^[0-9A-Za-z'\\-\\s]+$");
private static final Pattern ALLOWED_SEARCH_CHARS = Pattern.compile("^[0-9A-Za-z'\\-\\s]+$");

private final RequestValidations requestValidations;
private final ServiceUpdateOperationValidator serviceUpdateOperationValidator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void shouldAllowWellFormedRequest_whenSearchingServices() throws JsonProc

@Test
public void shouldAllowWellFormedRequest_whenSearchingServicesWithApostropheAndHyphen() throws JsonProcessingException {
var searchRequest = ServiceSearchRequest.from(mapper.readTree("{\"service_name\": \"test's test-name\"}"));
var searchRequest = ServiceSearchRequest.from(mapper.readTree("{\"service_name\": \"King’s Academy - 2\"}"));
Optional<Errors> errors = serviceRequestValidator.validateSearchRequest(searchRequest);
assertThat(errors.isPresent(), is(false));
}
Expand Down

0 comments on commit 9c596ff

Please sign in to comment.