Class NuitonFieldValidatorSupport
java.lang.Object
com.opensymphony.xwork2.validator.validators.ValidatorSupport
com.opensymphony.xwork2.validator.validators.FieldValidatorSupport
org.nuiton.validator.xwork2.field.NuitonFieldValidatorSupport
- All Implemented Interfaces:
com.opensymphony.xwork2.validator.FieldValidator,com.opensymphony.xwork2.validator.ShortCircuitableValidator,com.opensymphony.xwork2.validator.Validator
- Direct Known Subclasses:
CollectionUniqueKeyValidator,EmailFieldValidator,ExistingDirectoryFieldValidator,ExistingFileFieldValidator,FrenchCityNameFieldValidator,FrenchFinessFieldValidator,FrenchLastNameFieldValidator,FrenchPhoneNumberFieldValidator,FrenchPostCodeFieldValidator,FrenchSirenFieldValidator,FrenchSiretFieldValidator,NotExistingDirectoryFieldValidator,NotExistingFileFieldValidator,RequiredFileFieldValidator,SkipableRequiredFieldValidator,SkipableRequiredStringFieldValidator,VATIdentificationNumberFieldValidator
public abstract class NuitonFieldValidatorSupport
extends com.opensymphony.xwork2.validator.validators.FieldValidatorSupport
Nuiton default field validator.
This validator offers a
skip property that can be used to skip or
not the validator, this property is a OGNL expression.
To use this new field validator support, just now implements the method
validateWhenNotSkip(Object). This method will be invoked only if the skip
parameter is evaluated to false.- Since:
- 2.3
- Author:
- Tony Chemit - chemit@codelutin.com
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Stringskipextra parameter at the very beginning of thevalidate(Object)method to be able to skip (or not) the validator execution. -
Constructor Summary
Constructors Constructor Description NuitonFieldValidatorSupport() -
Method Summary
Modifier and Type Method Description protected booleanevaluateSkipParameter(java.lang.Object object)Evaluate the skip parameter value against the object to validate.java.lang.ObjectgetFieldValue(java.lang.String name, java.lang.Object object)voidsetSkip(java.lang.String skip)Sets the value of theskipparameter.voidvalidate(java.lang.Object object)protected abstract voidvalidateWhenNotSkip(java.lang.Object object)Method to be invoked when skip parameter was not evaludated totrue.Methods inherited from class com.opensymphony.xwork2.validator.validators.FieldValidatorSupport
getCurrentValue, getFieldName, getValidatorType, setFieldName, setValidatorTypeMethods inherited from class com.opensymphony.xwork2.validator.validators.ValidatorSupport
addActionError, addFieldError, getDefaultMessage, getMessage, getMessageKey, getMessageParameters, getValidatorContext, isShortCircuit, parse, setDefaultMessage, setMessageKey, setMessageParameters, setShortCircuit, setTextProviderFactory, setValidatorContext, setValueStack
-
Field Details
-
skip
protected java.lang.String skipextra parameter at the very beginning of thevalidate(Object)method to be able to skip (or not) the validator execution. by default the value isfalse: it seems fair to want to validate if the validator is used :D...
-
-
Constructor Details
-
NuitonFieldValidatorSupport
public NuitonFieldValidatorSupport()
-
-
Method Details
-
setSkip
public void setSkip(java.lang.String skip)Sets the value of theskipparameter.- Parameters:
skip- the new value of theskipparameter
-
validateWhenNotSkip
protected abstract void validateWhenNotSkip(java.lang.Object object) throws com.opensymphony.xwork2.validator.ValidationExceptionMethod to be invoked when skip parameter was not evaludated totrue.- Parameters:
object- the object to be validated.- Throws:
com.opensymphony.xwork2.validator.ValidationException- is thrown if there is validation error(s).
-
validate
public void validate(java.lang.Object object) throws com.opensymphony.xwork2.validator.ValidationException- Throws:
com.opensymphony.xwork2.validator.ValidationException
-
evaluateSkipParameter
protected boolean evaluateSkipParameter(java.lang.Object object) throws com.opensymphony.xwork2.validator.ValidationExceptionEvaluate the skip parameter value against the object to validate. This parameter can be an OGNL expression.- Parameters:
object- the object to validate- Returns:
- the evaluation of the skip parameter.
- Throws:
com.opensymphony.xwork2.validator.ValidationException- if could not evaluate the parameter
-
getFieldValue
public java.lang.Object getFieldValue(java.lang.String name, java.lang.Object object) throws com.opensymphony.xwork2.validator.ValidationException- Overrides:
getFieldValuein classcom.opensymphony.xwork2.validator.validators.ValidatorSupport- Throws:
com.opensymphony.xwork2.validator.ValidationException
-