nl.openedge.baritus.validation.impl
Class MinimumFieldLengthValidator

java.lang.Object
  extended bynl.openedge.baritus.validation.AbstractValidator
      extended bynl.openedge.baritus.validation.AbstractFieldValidator
          extended bynl.openedge.baritus.validation.impl.MinimumFieldLengthValidator
All Implemented Interfaces:
FieldValidator, ValidationRuleDependend

public final class MinimumFieldLengthValidator
extends AbstractFieldValidator

This validator checks on minimum length. If the type of the value is a String, the string length is checked. If the type of the value is a Number, the actual number is used. E.g. if property minLength is 4, "hello" will pass, but "hi" will fail, and number 5 will pass, but 2 will fail.

Author:
Eelco Hillenius

Field Summary
static int NO_MINIMUM
          special value that indicates there's no min value to check on
 
Constructor Summary
MinimumFieldLengthValidator()
          Construct with key invalid.field.input.size for error messages.
MinimumFieldLengthValidator(int minLength)
          Construct with min length.
MinimumFieldLengthValidator(java.lang.String errorMessageKey)
          Construct with message prefix for error message keys.
MinimumFieldLengthValidator(java.lang.String errorMessageKey, int minLength)
          Construct with message key for error message keys and set checking on minimum length with given length of fields only.
MinimumFieldLengthValidator(java.lang.String errorMessageKey, ValidationActivationRule rule)
          Construct with errorMessageKey and activation rule.
MinimumFieldLengthValidator(ValidationActivationRule rule)
          Construct with activation rule.
 
Method Summary
 java.lang.String getErrorMessageKey()
          Get key of error message.
 int getMinLength()
           
 boolean isValid(org.infohazard.maverick.flow.ControllerContext cctx, FormBeanContext formBeanContext, java.lang.String fieldName, java.lang.Object value)
          Checks whether the provided value is greater than the minimum.
 void setErrorMessageKey(java.lang.String string)
          Set key of error message.
 void setMinLength(int i)
           
 
Methods inherited from class nl.openedge.baritus.validation.AbstractFieldValidator
getOverrideValue
 
Methods inherited from class nl.openedge.baritus.validation.AbstractValidator
getFieldName, getLocalizedMessage, getLocalizedMessage, getLocalizedMessage, getLocalizedMessage, getValidationActivationRule, removeValidationActivationRule, setErrorMessage, setValidationRule
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface nl.openedge.baritus.validation.ValidationRuleDependend
getValidationActivationRule, removeValidationActivationRule, setValidationRule
 

Field Detail

NO_MINIMUM

public static final int NO_MINIMUM
special value that indicates there's no min value to check on

See Also:
Constant Field Values
Constructor Detail

MinimumFieldLengthValidator

public MinimumFieldLengthValidator()
Construct with key invalid.field.input.size for error messages.


MinimumFieldLengthValidator

public MinimumFieldLengthValidator(java.lang.String errorMessageKey)
Construct with message prefix for error message keys.

Parameters:
errorMessageKey - message key of error

MinimumFieldLengthValidator

public MinimumFieldLengthValidator(java.lang.String errorMessageKey,
                                   int minLength)
Construct with message key for error message keys and set checking on minimum length with given length of fields only.

Parameters:
errorMessageKey - key for error messages
minLength - minimum length allowed for values; use -1 for no minimum

MinimumFieldLengthValidator

public MinimumFieldLengthValidator(ValidationActivationRule rule)
Construct with activation rule.

Parameters:
rule - activation rule

MinimumFieldLengthValidator

public MinimumFieldLengthValidator(java.lang.String errorMessageKey,
                                   ValidationActivationRule rule)
Construct with errorMessageKey and activation rule.

Parameters:
errorMessageKey -
rule - activation rule

MinimumFieldLengthValidator

public MinimumFieldLengthValidator(int minLength)
Construct with min length.

Parameters:
minLength - minimum length allowed for values; use -1 for no minimum
Method Detail

isValid

public boolean isValid(org.infohazard.maverick.flow.ControllerContext cctx,
                       FormBeanContext formBeanContext,
                       java.lang.String fieldName,
                       java.lang.Object value)
Checks whether the provided value is greater than the minimum. In case the value is an instance of string: checks whether the length of the string is equal to or smaller than the minLength property. In case the value is an instance of number: checks whether the length of the integer value is equal to or smaller than the minLength property.

Parameters:
cctx - maverick context
formBeanContext - context with bean for this currentRequest
fieldName - field name of parameter
value - the value of this parameter
Returns:
boolean true if the length of value is equal to or less than the minLength property, false otherwise
See Also:
FieldValidator.isValid(org.infohazard.maverick.flow.ControllerContext, nl.openedge.baritus.FormBeanContext, java.lang.String, java.lang.Object)

getMinLength

public int getMinLength()
Returns:
int minimum length that is checked on

setMinLength

public void setMinLength(int i)
Parameters:
i - minimum length that is checked on

getErrorMessageKey

public java.lang.String getErrorMessageKey()
Get key of error message.

Returns:
String key of error message

setErrorMessageKey

public void setErrorMessageKey(java.lang.String string)
Set key of error message.

Parameters:
string - key of error message


Copyright © 2003-2004 Open Edge. All Rights Reserved.