org.springmodules.validation.bean.rule
Interface ValidationRule

All Known Implementing Classes:
AbstractValidationRule, ConditionReferenceValidationRule, DateInTheFutureValidationRule, DateInThePastValidationRule, DefaultValidationRule, EmailValidationRule, ExpressionValidationRule, InstantInTheFutureValidationRule, InstantInThePastValidationRule, LengthValidationRule, MaxLengthValidationRule, MaxSizeValidationRule, MaxValidationRule, MinLengthValidationRule, MinSizeValidationRule, MinValidationRule, NotBlankValidationRule, NotEmptyValidationRule, NotNullValidationRule, PropertyValidationRule, RangeValidationRule, RegExpValidationRule, SizeValidationRule, ValidationMethodValidationRule

public interface ValidationRule

Represents a validation rule. A validation rule binds an error to a condition.

Author:
Uri Boness

Method Summary
 Condition getCondition()
          Returns the condition of this validation rule.
 String getDefaultErrorMessage()
          Returns the default error message that can be used in case no error message is bound to the error code of the rule.
 Object[] getErrorArguments(Object obj)
          Returns the arguments that apply to the error code of this validation rule.
 String getErrorCode()
          Return the error code of this validation rule.
 boolean isApplicable(Object obj)
          Checks whether this validation is applicable on the given object.
 

Method Detail

isApplicable

boolean isApplicable(Object obj)
Checks whether this validation is applicable on the given object. This can be used to define applicability rules base on runtime factors.

Parameters:
obj - The object to be validated
Returns:
True if this validation rule is applicable on the given obj, false otherwise.

getCondition

Condition getCondition()
Returns the condition of this validation rule.

Returns:
The condition of this validation rule.

getErrorCode

String getErrorCode()
Return the error code of this validation rule. This method cannot return null.

Returns:
The error code of this validation rule.

getErrorArguments

Object[] getErrorArguments(Object obj)
Returns the arguments that apply to the error code of this validation rule. This method should never return null. If there are no arguments, this method must return an empty array. This method accepts the validated object, this enables runtime generation of arguments based on that object.

Parameters:
obj - The validated object.
Returns:
The arguments that apply to the error code of this validation rule.

getDefaultErrorMessage

String getDefaultErrorMessage()
Returns the default error message that can be used in case no error message is bound to the error code of the rule. This method can return null to indicate that no default message exists.

Returns:
The default error message of this validation rule.


Copyright © 2009. All Rights Reserved.