Class TravelFormValidator
java.lang.Object
de.hybris.platform.traveladdon.validators.TravelFormValidator
- Direct Known Subclasses:
APIFormValidator,CheckInValidator
Abstract form validator class containing common methods to validate travel specific forms
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidrejectValue(org.springframework.validation.Errors errors, String attributeName, String errorCode) Method to add errorsvoidrejectValue(org.springframework.validation.Errors errors, String attributeName, String errorCode, String[] params) Method to add errors with parametersbooleanvalidateAgainstRegEx(String value, org.springframework.validation.Errors errors, String attributeName, String expression) Method to validate value against a given expression.booleanvalidateDateFormat(String date, org.springframework.validation.Errors errors, String field) Method responsible for validating the date formatbooleanvalidateDocumentType(String documentType, org.springframework.validation.Errors errors, String attributeName) Validates the documentType provided with the DocumentType ENUM.booleanvalidateIsBlankField(String fieldValue, org.springframework.validation.Errors errors, String fieldName) Method to check if the value of the selected field either empty, null or contains only white spaces and if so it will set a EmptyField error against the fieldbooleanvalidateIsFutureDate(String date, org.springframework.validation.Errors errors, String field) Method returns true if the date is in the future.booleanvalidateIsPastDate(String date, org.springframework.validation.Errors errors, String field) Method returns true if the date is in the past.booleanvalidateMaxLength(String value, org.springframework.validation.Errors errors, String attributeName, int maxLength) Method checks to see if the value exceeds the maxLength.
-
Constructor Details
-
TravelFormValidator
public TravelFormValidator()
-
-
Method Details
-
validateDateFormat
public boolean validateDateFormat(String date, org.springframework.validation.Errors errors, String field) Method responsible for validating the date format- Parameters:
date-errors-field-- Returns:
-
validateIsPastDate
public boolean validateIsPastDate(String date, org.springframework.validation.Errors errors, String field) Method returns true if the date is in the past. Date is evaluated on the current date.- Parameters:
date-errors-field-- Returns:
-
validateIsFutureDate
public boolean validateIsFutureDate(String date, org.springframework.validation.Errors errors, String field) Method returns true if the date is in the future. Date is evaluated on the current date.- Parameters:
date-errors-field-- Returns:
-
validateIsBlankField
public boolean validateIsBlankField(String fieldValue, org.springframework.validation.Errors errors, String fieldName) Method to check if the value of the selected field either empty, null or contains only white spaces and if so it will set a EmptyField error against the field- Parameters:
fieldValue-errors-fieldName-- Returns:
-
validateDocumentType
public boolean validateDocumentType(String documentType, org.springframework.validation.Errors errors, String attributeName) Validates the documentType provided with the DocumentType ENUM. If the documentType provided is not a valid DocumentType, an error will be added to the list of validation errors- Parameters:
documentType-errors-attributeName-- Returns:
-
validateAgainstRegEx
public boolean validateAgainstRegEx(String value, org.springframework.validation.Errors errors, String attributeName, String expression) Method to validate value against a given expression. Method will return false if regex fails and true if regex passes.- Parameters:
value-errors-attributeName-expression-- Returns:
-
validateMaxLength
public boolean validateMaxLength(String value, org.springframework.validation.Errors errors, String attributeName, int maxLength) Method checks to see if the value exceeds the maxLength. Method returns true if it does and false if it doesn't.- Parameters:
value-errors-attributeName-maxLength-- Returns:
-
rejectValue
public void rejectValue(org.springframework.validation.Errors errors, String attributeName, String errorCode) Method to add errors- Parameters:
errors-attributeName-errorCode-
-
rejectValue
public void rejectValue(org.springframework.validation.Errors errors, String attributeName, String errorCode, String[] params) Method to add errors with parameters- Parameters:
errors-attributeName-errorCode-
-