I am validating the bins. Despite entering the correct format, I get errors. When checking for regulars with IDEA itself, I get the right format, check below with screenshots.

Comparisons occur with this algorithm.

if (!(regEx.matches(fieldValue.toString()))) { validationConstraints.add(errorMessage +" -> the value is: "+fieldValue.toString()); } 

Inside Bina annotations:

 @NotEmptyFieldValidation(message = "User first name field can't be empty!") @LengthValidation(min = 3,max = 20,message = "First name need to be 3 - 20 characters!") private String firstName; @NotEmptyFieldValidation(message = "User last name field can't be empty!") @LengthValidation(min = 3,max = 20,message = "Last name need to be 3 - 20 characters!") private String lastName; @NotEmptyFieldValidation(message = "User password field can't be empty!") @PasswordFormatValidation(regEx = "((?=.*\\d)(?=.*[az])(?=.*[AZ])(?=.*[@#$%]).{6,20})", message = "User wrong password format! Valid combination is 6 to 20 characters string with at least one digit, one upper case letter, one lower case letter and one special symbol (“@#$%”).") private String password; @NotEmptyFieldValidation(message = "User type field can't be empty!") @EmailFormatValidation(message = "User wrong email format! Valid characters are: AZ big character with az small character with '.' and '0-9', then after '@' AZ or az with '.', and then az small characters between 2-4 length!", regularExpression = "[A-Za-z.0-9]+@[A-Za-z.]+.[az]{2,4}") private String email; @NotEmptyFieldValidation(message = "User type field can't be empty!") @LengthValidation(message = "The length of customer type can be only 7 - 16", min = 7, max = 16) private String customerType; @NotEmptyFieldValidation(message = "User name field can't be empty!") @NickNameValidation(regEX = "^[a-z0-9_-]{3,15}$", nickNameMessage = "User name format is wrong! It must be 3 to 15 characters with any lower case character, digit or special symbol “_-” only") private String nickName; 

Output constraints:

User name format is wrong! It should be 3 - 15 characters

User wrong email format! Valid characters are: AZ big character with az small character with '.' and '0-9', then after '@' AZ or az with '.', and then az small characters between 2-4 length! -> the value is: Maks.Burkov1998@gmail.com

User wrong password format! At least one digit is one character string (“@ # $%”). -> the value is: luda1Ms #

enter image description here enter image description here enter image description here

The data that I send via Postman! Json

  { "firstName":"maksimus", "lastName":"burkovus", "nickName":"maksm99", "companyId":"0909876", "companyName":"maksCompany", "customerType":"company", "email":"Maks.Burkov1998@gmail.com", "password":"luda1Ms#" } 

    1 answer 1

    You mixed up the string and the regular expression. It should be like this:

     "строка".matches("регулярное выражение") 

    and if you have the opposite.