com.sas.util.validators
Interface ValidationInterface

All Known Subinterfaces:
JavaScriptValidationInterface
All Known Implementing Classes:
CompositeValidator, DateStringValidator, DateStringValidator, HexColorStringValidator, IntegerInputValidator, IntegerStringValidator, JavaScriptValidator, MaximumLengthValidator, MaximumValueCompositeValidator, MaximumValueValidator, MinimumValueCompositeValidator, MinimumValueValidator, MinMaxIntegerStringValidator, MinMaxValueCompositeValidator, NumericInputValidator, RequiredStringValidator, RequiredStringValidator, Validator

public interface ValidationInterface

ValidationInterface is used to allow an object to validate input, normalize input and return error information when the information is invalid.

The ValidationInterface was designed to be used by input components such as the TextField. Components which used validators should implement the ValidatorInterface so that there is a standard way to set/get the validator.

com.sas.util.validators.Validator is a default implementation of the ValidationInterface.


Method Summary
 com.sas.text.Message getValidationMessage()
          Returns the validation message set when validateValue() last returned false.
 java.lang.String getValidationMessageCode()
          Returns the validation message code set when validateValue() last returned false.
 java.lang.Object normalizeValue(java.lang.Object component, java.lang.Object value)
          Allows the validator to modify the value after it has been deemed valid.
 void setValidationMessage(com.sas.text.Message message)
          Sets the validation message which indicates why validateValue() returned false.
 boolean validateValue(java.lang.Object component, java.lang.Object value)
          Validates the value passed in (possibly) based on information from the component passed in.
 

Method Detail

validateValue

boolean validateValue(java.lang.Object component,
                      java.lang.Object value)
Validates the value passed in (possibly) based on information from the component passed in.

Parameters:
component - an object containing the value
value - the value to be validated
Returns:
true if the value us valid, false if not. If false is returned, the validator should call setValidationMessage with a String for a reason.

normalizeValue

java.lang.Object normalizeValue(java.lang.Object component,
                                java.lang.Object value)
Allows the validator to modify the value after it has been deemed valid. The object doing the validation should call validateValue() on the value before passing it to normalizeValue(). Only if validateValue() returns true should normalizeValue() be called.

This might be used to change a valid date such as "5/5/96" into a normalized form such as "May 5, 1996".

Parameters:
component - an object containing the value
value - the value to be normalized
Returns:
the normalized value. This can be the input value or a value drived from it.

getValidationMessageCode

java.lang.String getValidationMessageCode()
Returns the validation message code set when validateValue() last returned false.

Returns:
a validation message code. The validation message code is a non-translatable string which identifies the cause of the last validation error. This will typically be used as a key to a resource bundle.

getValidationMessage

com.sas.text.Message getValidationMessage()
Returns the validation message set when validateValue() last returned false.

Returns:
the Message object, containing a format string and substitution values, which describe why the value passed to validateValue() is invalid.

setValidationMessage

void setValidationMessage(com.sas.text.Message message)
Sets the validation message which indicates why validateValue() returned false.

Parameters:
message - a Message object that contains a format string and substitution values, which describe why the value passed to validateValue() is invalid.



Copyright © 2009 SAS Institute Inc. All Rights Reserved.