Skip to content

Commit

Permalink
AYS-528 | The Validations Were Set Up In Accordance With The Standard…
Browse files Browse the repository at this point in the history
…s. (#398)
  • Loading branch information
MenekseYuncu authored Nov 14, 2024
1 parent 594c938 commit 183c30b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class NameValidator implements ConstraintValidator<Name, String> {
* It also avoids strings that start with special characters
* </p>
*/
private static final String NAME_REGEX = "^(?![^a-zA-ZÇçĞğİıÖöŞşÜü])[a-zA-ZÇçĞğİıÖöŞşÜü ,.'-]*$";
private static final String NAME_REGEX = "^(?!.*[ ,.'-]{2})[a-zA-ZÇçĞğİıÖöŞşÜü]+(?:[ ,.'-](?![ ,.'-])[a-zA-ZÇçĞğİıÖöŞşÜü]+)*$";

/**
* Checks whether the given value is a valid name or not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,10 @@ void givenPhoneNumberWithInvalidOperator_whenPhoneNumberIsNotValid_thenReturnVal
"John *^%$#",
" John",
"? John",
"J"
"J",
"J----",
"City--King",
"John Doe"
})
void givenInvalidAdminRegisterApplicationCompleteRequestWithParametrizedInvalidNames_whenNamesAreNotValid_thenReturnValidationError(String invalidName) throws Exception {

Expand Down
11 changes: 10 additions & 1 deletion src/test/java/org/ays/auth/controller/AysRoleControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ void givenValidRoleListRequest_whenRolesFound_thenReturnAysPageResponseOfRolesRe
"Role *^%$#",
" Test",
"? Role",
"J"
"J",
"J----",
"City--King",
"John Doe"
})
void givenRoleListRequest_whenNameDoesNotValid_thenReturnValidationError(String invalidName) throws Exception {

Expand Down Expand Up @@ -383,6 +386,9 @@ void givenValidRoleCreateRequest_whenUserUnauthorized_thenReturnAccessDeniedExce
" Kurum yöneticisi",
"!Kurum",
"12Kurum",
"J----",
"City--King",
"John Doe",
"A",
"% fsdh ",
"493268349068342",
Expand Down Expand Up @@ -591,6 +597,9 @@ void givenInvalidIdAndValidRoleUpdateRequest_whenIdNotValid_thenReturnValidation
" Role",
"Role ",
"123Role",
"J----",
"City--King",
"John Doe",
".Role",
"% fsdh ",
"493268349068342",
Expand Down
15 changes: 12 additions & 3 deletions src/test/java/org/ays/auth/controller/AysUserControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ void givenValidUserListRequest_whenUsersFound_thenReturnAysPageResponseOfUsersRe
"User *^%$#",
" Test",
"? User",
"J"
"J",
"J----",
"Martin-Luther--King",
"John Doe"
})
void givenUserListRequest_whenFirstNameDoesNotValid_thenReturnValidationError(String invalidName) throws Exception {

Expand Down Expand Up @@ -144,7 +147,10 @@ void givenUserListRequest_whenFirstNameDoesNotValid_thenReturnValidationError(St
"User *^%$#",
" Test",
"? User",
"J"
"J",
"J----",
"Martin-Luther--King",
"John Doe"
})
void givenUserListRequest_whenLastNameDoesNotValid_thenReturnValidationError(String invalidName) throws Exception {

Expand Down Expand Up @@ -178,7 +184,10 @@ void givenUserListRequest_whenLastNameDoesNotValid_thenReturnValidationError(Str
"City *^%$#",
" Test",
"? User",
"J"
"J",
"J----",
"City--King",
"John Doe"
})
void givenUserListRequest_whenCityDoesNotValid_thenReturnValidationError(String invalidName) throws Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,9 @@ void givenEmergencyEvacuationApplicationId_whenUnauthorizedForGettingEmergencyEv
@ValueSource(strings = {
"Invalid with special characters: #$%",
".,..,.,.,.,.,,.,.,.,.,.,.,.,.,..,.,.,,.,.,.,",
"J----",
"City--King",
"John Doe",
"t",
" a",
"151201485621548562154851458614125461254125412",
Expand Down Expand Up @@ -510,6 +513,9 @@ void givenInvalidEmergencyEvacuationApplicationRequest_whenPhoneNumbersAreSameOn
"Invalid with special characters: #$%",
"#$½#$£#$£#$$#½#£$£#$#£½#$½#$½$£#$#£$$#½#$$½",
".,..,.,.,.,.,,.,.,.,.,.,.,.,.,..,.,.,,.,.,.,",
"J----",
"City--King",
"John Doe",
"t",
" a",
"151201485621548562154851458614125461254125412",
Expand Down Expand Up @@ -545,6 +551,9 @@ void givenInvalidEmergencyEvacuationApplicationRequest_whenFirstNameIsNotValid_t
"Invalid with special characters: #$%",
"#$½#$£#$£#$$#½#£$£#$#£½#$½#$½$£#$#£$$#½#$$½",
".,..,.,.,.,.,,.,.,.,.,.,.,.,.,..,.,.,,.,.,.,",
"J----",
"City--King",
"John Doe",
"t",
" a",
"151201485621548562154851458614125461254125412",
Expand Down Expand Up @@ -817,6 +826,9 @@ void givenInvalidEmergencyEvacuationApplicationRequest_whenTargetDistrictIsNotVa
"#$½#$£#$£#$$#½#£$£#$#£½#$½#$½$£#$#£$$#½#$$½",
".,..,.,.,.,.,,.,.,.,.,.,.,.,.,..,.,.,,.,.,.,",
"t",
"J----",
"City--King",
"John Doe",
" a",
"151201485621548562154851458614125461254125412",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam In hac habitasse platea dictumst. Nullam in turpis at nunc ultrices.",
Expand Down Expand Up @@ -852,6 +864,9 @@ void givenInvalidEmergencyEvacuationApplicationRequest_whenApplicantFirstNameIsN
"#$½#$£#$£#$$#½#£$£#$#£½#$½#$½$£#$#£$$#½#$$½",
".,..,.,.,.,.,,.,.,.,.,.,.,.,.,..,.,.,,.,.,.,",
"t",
"J----",
"City--King",
"John Doe",
" a",
"151201485621548562154851458614125461254125412",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam In hac habitasse platea dictumst. Nullam in turpis at nunc ultrices.",
Expand Down

0 comments on commit 183c30b

Please sign in to comment.