org.apache.turbine.services.intake.validator
Class DefaultValidator

java.lang.Object
  |
  +--org.apache.turbine.services.intake.validator.DefaultValidator
All Implemented Interfaces:
Validator
Direct Known Subclasses:
NumberValidator

public class DefaultValidator
extends java.lang.Object
implements Validator

A validator that will compare a testValue against the following constraints:
NameValid ValuesDefault Value
requiredtrue|falsefalse
maskregexp 
minLengthinteger0
maxLengthinteger 
This validator can serve as the base class for more specific validators

Version:
$Id$
Author:
Field Summary
protected  org.apache.regexp.RE mask
           
protected  java.lang.String maskMessage
           
protected  int maxLength
           
protected  java.lang.String maxLengthMessage
           
protected  java.lang.String message
           
protected  int minLength
           
protected  java.lang.String minLengthMessage
           
protected  boolean required
           
protected  java.lang.String requiredMessage
           
 
Constructor Summary
DefaultValidator()
           
DefaultValidator(java.util.Map paramMap)
           
 
Method Summary
 void assertValidity(java.lang.String testValue)
          Determine whether a testValue meets the criteria specified in the constraints defined for this validator
protected  void doAssertValidity(java.lang.String testValue)
          Method to allow subclasses to add additional validation
 int getMaxLength()
          This value can be used to construct a form input field so lets make it available
 java.lang.String getMessage()
          Get the last error message resulting from invalid input.
 void init(java.util.Map paramMap)
          Extract the relevant parameters from the constraints listed in tags within the intake.xml file.
 boolean isValid(java.lang.String testValue)
          Determine whether a testValue meets the criteria specified in the constraints defined for this validator
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

required

protected boolean required

requiredMessage

protected java.lang.String requiredMessage

mask

protected org.apache.regexp.RE mask

maskMessage

protected java.lang.String maskMessage

minLength

protected int minLength

minLengthMessage

protected java.lang.String minLengthMessage

maxLength

protected int maxLength

maxLengthMessage

protected java.lang.String maxLengthMessage

message

protected java.lang.String message
Constructor Detail

DefaultValidator

public DefaultValidator(java.util.Map paramMap)
                 throws TurbineException

DefaultValidator

public DefaultValidator()
Method Detail

init

public void init(java.util.Map paramMap)
          throws TurbineException
Extract the relevant parameters from the constraints listed in tags within the intake.xml file.
Specified by:
init in interface Validator
Parameters:
paramMap - a Map of Rule's containing constraints on the input.
Throws:
TurbineException - if an error occurs

isValid

public boolean isValid(java.lang.String testValue)
Determine whether a testValue meets the criteria specified in the constraints defined for this validator
Specified by:
isValid in interface Validator
Parameters:
testValue - a String to be tested
Returns:
true if valid, false otherwise

assertValidity

public void assertValidity(java.lang.String testValue)
                    throws ValidationException
Determine whether a testValue meets the criteria specified in the constraints defined for this validator
Specified by:
assertValidity in interface Validator
Parameters:
testValue - a String to be tested
Throws:
ValidationException - containing an error message if the testValue did not pass the validation tests.

getMessage

public java.lang.String getMessage()
Get the last error message resulting from invalid input.
Specified by:
getMessage in interface Validator
Returns:
a String message, or the empty String "".

doAssertValidity

protected void doAssertValidity(java.lang.String testValue)
                         throws ValidationException
Method to allow subclasses to add additional validation

getMaxLength

public int getMaxLength()
This value can be used to construct a form input field so lets make it available


Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.