public class ValidationHelper extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
PORT_NUMBERS_MAX_LENGTH
max length for port numbers
|
static int |
PORT_NUMBERS_MIN_LENGTH
min length for port numbers
|
static String |
PORT_NUMBERS_REGEX
regex for port numbers
|
static String |
REGEX_DIGITS
regex for numbers only
|
static String |
STRING_GREATER_MAX
Contains a message property.
|
static String |
STRING_SMALLER_MIN
Contains a message property.
|
static String |
STRING_WRONG_REGEX_FORMAT
Contains a message property.
|
static String |
STRING_WRONG_REGEX_FORMAT_ALL_DIGITS |
static String |
STRING_WRONG_REGEX_FORMAT_ALL_LETTERS |
static String |
STRING_WRONG_REGEX_FORMAT_ALL_LETTERS_AND_OTHER |
| Modifier and Type | Method and Description |
|---|---|
static String |
getRegexForDisplay(String regex)
Modifies the regex Expression to show it the user with the characters which are allowed.
|
static boolean |
validateEmail(String fieldName,
String input,
boolean isRequired,
org.springframework.validation.Errors errors)
Validate the e-mail address.
|
static boolean |
validatePasswords(UserPasswordManagement userPasswordManagement,
String passwordField,
String passwordInput,
String passwordConfirmField,
String passwordConfirmInput,
org.springframework.validation.Errors errors) |
static void |
validatePhoneNumber(PhoneNumber phoneNumber,
String field,
org.springframework.validation.Errors errors,
boolean required)
Validates a phone number.
|
static boolean |
validatePortNumber(String fieldName,
String input,
boolean isRequired,
org.springframework.validation.Errors errors)
Validate port numbers.
|
static void |
validateString(String field,
org.springframework.validation.Errors errors,
String pattern,
int minLength,
int maxLength)
Validates a string.
|
static boolean |
validateString(String fieldName,
String input,
boolean isRequired,
int maxLen,
int minLen,
String regex,
org.springframework.validation.Errors errors)
Validates a string.
|
static String |
validateStringByRegex(String inputStr,
String regex,
String field,
org.springframework.validation.Errors errors)
Validates a string by regular expression.
|
public static final String STRING_SMALLER_MIN
public static final String STRING_GREATER_MAX
public static final String STRING_WRONG_REGEX_FORMAT
public static final String STRING_WRONG_REGEX_FORMAT_ALL_LETTERS
public static final String STRING_WRONG_REGEX_FORMAT_ALL_LETTERS_AND_OTHER
public static final String STRING_WRONG_REGEX_FORMAT_ALL_DIGITS
public static final String REGEX_DIGITS
public static final String PORT_NUMBERS_REGEX
public static final int PORT_NUMBERS_MIN_LENGTH
public static final int PORT_NUMBERS_MAX_LENGTH
public static String getRegexForDisplay(String regex)
regex - Regex to modifypublic static boolean validateEmail(String fieldName, String input, boolean isRequired, org.springframework.validation.Errors errors)
fieldName - the field name.input - the input of the field.isRequired - true if the input must contain a valueerrors - the error object.true if the e-mail address is valid otherwise falsepublic static boolean validatePasswords(UserPasswordManagement userPasswordManagement, String passwordField, String passwordInput, String passwordConfirmField, String passwordConfirmInput, org.springframework.validation.Errors errors)
userPasswordManagement - the user password management servicepasswordField - the name of the password field.passwordInput - the password.passwordConfirmField - the name of the field to confirm the password.passwordConfirmInput - the password confirmationerrors - Errors.true if the password is valid otherwise falsepublic static void validatePhoneNumber(PhoneNumber phoneNumber, String field, org.springframework.validation.Errors errors, boolean required)
phoneNumber - the phone number to validatefield - the field to checkerrors - the errosrequired - If set, a number must be set, else a number can be set.public static boolean validatePortNumber(String fieldName, String input, boolean isRequired, org.springframework.validation.Errors errors)
fieldName - the field name.input - the input of the field.isRequired - true if the input must contain a valueerrors - the error object.true if the port number is valid otherwise falsepublic static void validateString(String field, org.springframework.validation.Errors errors, String pattern, int minLength, int maxLength)
field - the fielderrors - the errorspattern - The regular expression to use.minLength - Minimal length of the field.maxLength - Maximal length of the field.public static boolean validateString(String fieldName, String input, boolean isRequired, int maxLen, int minLen, String regex, org.springframework.validation.Errors errors)
fieldName - the field name.input - the input of the field.isRequired - true if the input must contain a valuemaxLen - the max length of chars, can be a negative number to skip this testminLen - the minimum length of chars, can be zero to skip this testregex - A regular expression for the given string, can be null to skip this testerrors - the error object (reference to a BindException object).true if the string is valid otherwise falsepublic static String validateStringByRegex(String inputStr, String regex, String field, org.springframework.validation.Errors errors)
inputStr - Stringregex - A regular expression for the given string, can be nullfield - the field name (may be null or empty String)errors - Reference to a BindException object. If this parameter null then field will be not
rejectedCopyright © 2019 Communote team. All rights reserved.