public abstract class SpincastValidatorBase<T> extends Object implements IValidator
| Constructor and Description |
|---|
SpincastValidatorBase(T objToValidate,
SpincastValidatorBaseDeps spincastValidatorBaseDeps)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addError(IValidationError error)
Adds a validation error.
|
protected void |
addError(String fieldName,
String errorType,
String errorMessage)
Adds a validation error.
|
protected void |
addErrors(List<IValidationError> errors)
Adds validation errors.
|
protected void |
addErrorsFormattedSpecificField(String fieldName,
List<IValidationError> errors,
FormatType formatType,
StringBuilder textBuilder,
IJsonObject jsonObject) |
protected void |
addErrorsFormattedSpecificFieldHtml(String fieldName,
StringBuilder textBuilder,
List<IValidationError> errors) |
protected void |
addErrorsFormattedSpecificFieldTextPlain(String fieldName,
StringBuilder textBuilder,
List<IValidationError> errors) |
protected String |
getCssClassForErrorField()
The css class to use for a field's <li> element.
|
protected String |
getCssClassForErrorMessage()
The css class to use for an error message's <li> element.
|
protected String |
getDefaultErrorMessage(String fieldName) |
protected org.apache.commons.validator.routines.EmailValidator |
getEmailValidator() |
protected String |
getErrorMessageDefaultMaxLength(String fieldName,
long maxLength,
long currentLength) |
protected String |
getErrorMessageDefaultMaxSize(String fieldName,
long maxSize,
Long currentSize) |
protected String |
getErrorMessageDefaultMinLength(String fieldName,
long minLength,
long currentLength) |
protected String |
getErrorMessageDefaultMinSize(String fieldName,
long minSize,
Long currentSize) |
protected String |
getErrorMessageDefaultNotBlank(String fieldName) |
protected String |
getErrorMessageDefaultNotNull(String fieldName) |
protected String |
getErrorMessageDefaultPattern(String fieldName,
String pattern) |
protected String |
getErrorMessageEmail(String fieldName) |
Map<String,List<IValidationError>> |
getErrors()
Gets the validation errors.
|
List<IValidationError> |
getErrors(String fieldName)
Gets the validation errors for the specified field.
|
String |
getErrorsFormatted(FormatType formatType)
Gets the formatted errors, if there are any.
|
String |
getErrorsFormatted(String fieldName,
FormatType formatType)
Gets the formatted errors of a specific field, if there are any.
|
protected Map<String,List<IValidationError>> |
getErrorsMap() |
protected IJsonManager |
getJsonManager() |
protected T |
getObjToValidate() |
protected ISpincastValidationConfig |
getSpincastBeanValidationConfig() |
protected IValidationErrorFactory |
getValidationErrorFactory() |
protected IXmlManager |
getXmlManager() |
boolean |
isValid()
Is the object valid?
|
protected boolean |
isValidationDone() |
void |
revalidate()
Revalidates the object.
|
protected boolean |
usePrettyJson() |
protected boolean |
usePrettyXml() |
protected abstract void |
validate()
The validation method to implement.
|
protected void |
validateBase()
Override "validate()" instead of
this method, if you can.
|
protected boolean |
validateEmail(String fieldName,
String fieldValue)
Validates that a field is a valid email address.
|
protected boolean |
validateEmail(String fieldName,
String fieldValue,
String errorMessage)
Validates that a field is a valid email address.
|
protected boolean |
validateMaxLength(String fieldName,
String fieldValue,
int maxLength)
Validates that a field has a maximum length.
|
protected boolean |
validateMaxLength(String fieldName,
String fieldValue,
int maxLength,
String errorMessage)
Validates that a field has a maximum length.
|
protected boolean |
validateMaxLength(String fieldName,
String fieldValue,
long maxLength)
Validates that a field has a maximum length.
|
protected boolean |
validateMaxLength(String fieldName,
String fieldValue,
long maxLength,
String errorMessage)
Validates that a field has a maximum length.
|
protected boolean |
validateMaxSize(String fieldName,
Integer fieldValue,
int maxSize)
Validates that a field has a maximum size.
|
protected boolean |
validateMaxSize(String fieldName,
Integer fieldValue,
int maxSize,
String errorMessage)
Validates that a field has a maximum size.
|
protected boolean |
validateMaxSize(String fieldName,
Long fieldValue,
long maxSize)
Validates that a field has a maximum size.
|
protected boolean |
validateMaxSize(String fieldName,
Long fieldValue,
long maxSize,
String errorMessage)
Validates that a field has a minimum size.
|
protected boolean |
validateMinLength(String fieldName,
String fieldValue,
int minLength)
Validates that a field has a minimum length.
|
protected boolean |
validateMinLength(String fieldName,
String fieldValue,
int minLength,
String errorMessage)
Validates that a field has a minimum length.
|
protected boolean |
validateMinLength(String fieldName,
String fieldValue,
long minLength)
Validates that a field has a minimum length.
|
protected boolean |
validateMinLength(String fieldName,
String fieldValue,
long minLength,
String errorMessage)
Validates that a field has a minimum length.
|
protected boolean |
validateMinSize(String fieldName,
Integer fieldValue,
int minSize)
Validates that a field has a minimum size.
|
protected boolean |
validateMinSize(String fieldName,
Integer fieldValue,
int minSize,
String errorMessage)
Validates that a field has a minimum size.
|
protected boolean |
validateMinSize(String fieldName,
Long fieldValue,
long minSize)
Validates that a field has a minimum size.
|
protected boolean |
validateMinSize(String fieldName,
Long fieldValue,
long minSize,
String errorMessage)
Validates that a field has a minimum size.
|
protected boolean |
validateNotBlank(String fieldName,
String fieldValue)
Validates that a field is not blank (null, empty or contain only spaces).
|
protected boolean |
validateNotBlank(String fieldName,
String fieldValue,
String errorMessage)
Validates that a field is not null.
|
protected boolean |
validateNotNull(String fieldName,
Object fieldValue)
Validates that a field is not null.
|
protected boolean |
validateNotNull(String fieldName,
Object fieldValue,
String errorMessage)
Validates that a field is not null.
|
protected boolean |
validatePattern(String fieldName,
String fieldValue,
String pattern)
Validates that a field matches a pattern.
|
protected boolean |
validatePattern(String fieldName,
String fieldValue,
String pattern,
boolean mustMatch)
Validates that a field matches a pattern or not.
|
protected boolean |
validatePattern(String fieldName,
String fieldValue,
String pattern,
boolean mustMatch,
String errorMessage)
Validates that a field matches a pattern or not.
|
protected boolean |
validatePattern(String fieldName,
String fieldValue,
String pattern,
String errorMessage)
Validates that a field matches a pattern.
|
public SpincastValidatorBase(T objToValidate, SpincastValidatorBaseDeps spincastValidatorBaseDeps)
protected T getObjToValidate()
protected IValidationErrorFactory getValidationErrorFactory()
protected ISpincastValidationConfig getSpincastBeanValidationConfig()
protected IJsonManager getJsonManager()
protected IXmlManager getXmlManager()
protected boolean isValidationDone()
protected void validateBase()
public boolean isValid()
IValidatorisValid in interface IValidatorpublic void revalidate()
IValidatorrevalidate in interface IValidatorpublic Map<String,List<IValidationError>> getErrors()
IValidatorIf the validation hasn't been called yet, calls it.
getErrors in interface IValidatorprotected Map<String,List<IValidationError>> getErrorsMap()
public List<IValidationError> getErrors(String fieldName)
IValidatorIf the validation hasn't been called yet, calls it.
getErrors in interface IValidatorprotected void addError(IValidationError error)
protected void addError(String fieldName, String errorType, String errorMessage)
protected void addErrors(List<IValidationError> errors)
public String getErrorsFormatted(FormatType formatType)
IValidatorIf the validation hasn't been called yet, calls it.
getErrorsFormatted in interface IValidatorformatType - The type of output for the errors (Text, HTML, Json or XML).null if
there are no validation errors.public String getErrorsFormatted(String fieldName, FormatType formatType)
IValidatorIf the validation hasn't been called yet, calls it.
getErrorsFormatted in interface IValidatorfieldName - The field to get errors for.formatType - The type of output for the errors (Text, HTML, Json or XML).null if
there are no validation errors.protected boolean usePrettyJson()
protected boolean usePrettyXml()
protected void addErrorsFormattedSpecificField(String fieldName, List<IValidationError> errors, FormatType formatType, StringBuilder textBuilder, IJsonObject jsonObject)
protected void addErrorsFormattedSpecificFieldTextPlain(String fieldName, StringBuilder textBuilder, List<IValidationError> errors)
protected void addErrorsFormattedSpecificFieldHtml(String fieldName, StringBuilder textBuilder, List<IValidationError> errors)
protected String getCssClassForErrorField()
protected String getCssClassForErrorMessage()
protected boolean validateNotNull(String fieldName, Object fieldValue)
protected boolean validateNotNull(String fieldName, Object fieldValue, String errorMessage)
protected boolean validateNotBlank(String fieldName, String fieldValue)
protected boolean validateNotBlank(String fieldName, String fieldValue, String errorMessage)
protected boolean validateMinLength(String fieldName, String fieldValue, int minLength)
protected boolean validateMinLength(String fieldName, String fieldValue, int minLength, String errorMessage)
protected boolean validateMinLength(String fieldName, String fieldValue, long minLength)
protected boolean validateMinLength(String fieldName, String fieldValue, long minLength, String errorMessage)
protected String getErrorMessageDefaultMinLength(String fieldName, long minLength, long currentLength)
protected boolean validateMaxLength(String fieldName, String fieldValue, int maxLength)
protected boolean validateMaxLength(String fieldName, String fieldValue, int maxLength, String errorMessage)
protected boolean validateMaxLength(String fieldName, String fieldValue, long maxLength)
protected boolean validateMaxLength(String fieldName, String fieldValue, long maxLength, String errorMessage)
protected String getErrorMessageDefaultMaxLength(String fieldName, long maxLength, long currentLength)
protected boolean validateMinSize(String fieldName, Integer fieldValue, int minSize)
protected boolean validateMinSize(String fieldName, Integer fieldValue, int minSize, String errorMessage)
protected boolean validateMinSize(String fieldName, Long fieldValue, long minSize)
protected boolean validateMinSize(String fieldName, Long fieldValue, long minSize, String errorMessage)
protected String getErrorMessageDefaultMinSize(String fieldName, long minSize, Long currentSize)
protected boolean validateMaxSize(String fieldName, Integer fieldValue, int maxSize)
protected boolean validateMaxSize(String fieldName, Integer fieldValue, int maxSize, String errorMessage)
protected boolean validateMaxSize(String fieldName, Long fieldValue, long maxSize)
protected boolean validateMaxSize(String fieldName, Long fieldValue, long maxSize, String errorMessage)
protected String getErrorMessageDefaultMaxSize(String fieldName, long maxSize, Long currentSize)
protected boolean validatePattern(String fieldName, String fieldValue, String pattern)
protected boolean validatePattern(String fieldName, String fieldValue, String pattern, boolean mustMatch)
mustMatch - if true, the field must match the pattern, if
false, it must not match it.protected boolean validatePattern(String fieldName, String fieldValue, String pattern, String errorMessage)
protected boolean validatePattern(String fieldName, String fieldValue, String pattern, boolean mustMatch, String errorMessage)
mustMatch - if true, the field must match the pattern, if
false, it must not match it.protected String getErrorMessageDefaultPattern(String fieldName, String pattern)
protected boolean validateEmail(String fieldName, String fieldValue)
protected boolean validateEmail(String fieldName, String fieldValue, String errorMessage)
protected org.apache.commons.validator.routines.EmailValidator getEmailValidator()
protected abstract void validate()
Copyright © 2016. All rights reserved.