com.cafesoft.core.field
Class StringValidationRule

java.lang.Object
  |
  +--com.cafesoft.core.field.DefaultFieldValidationRule
        |
        +--com.cafesoft.core.field.StringValidationRule
All Implemented Interfaces:
FieldValidationRule

public class StringValidationRule
extends DefaultFieldValidationRule

StringValidationRule validates all String FieldType field values to ensure that the value conform to the rules of the field.

Since:
8/12/03
See Also:
DefaultFieldValidationRule, FieldValidationRule

Field Summary
 
Fields inherited from class com.cafesoft.core.field.DefaultFieldValidationRule
fieldInfo
 
Constructor Summary
StringValidationRule(FieldInfo fieldInfo)
          Create a new StringValidationRule
 
Method Summary
 void validate(Object fieldValue)
          Assert validity of a Field value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringValidationRule

public StringValidationRule(FieldInfo fieldInfo)
Create a new StringValidationRule

Parameters:
fieldInfo - field level metadata object.
Throws:
NullPointerException - if fieldInfo is null.
Method Detail

validate

public void validate(Object fieldValue)
              throws InvalidFieldValueException
Assert validity of a Field value.

The StringValidationRule will validate a fieldValue under the following conditions:

  1. If the fieldValue is null and a null value is allowed the fieldValue is valid, otherwise if null is not allowed the fieldValue is invalid.
  2. If the fieldValue is not an instance of a String object then the fieldValue object is invalid.
  3. If the FieldInfo object contains a FieldValueOptions class and the fieldValue is not a value contained by that class then the fieldValue object is invalid.
  4. If the fieldValue contains multiple wildcard characters, the wildcard characters must be the first and last character of the fieldValue object. In addition, the fieldValue must not contain more than 2 wildcard characters. If any of these stipulations are not met then the fieldValue object is invalid.
  5. If the FieldInfo object has a minimum length requirement and the fieldValue object is less than the minimum length the fieldValue object is invalid.
  6. If the FieldInfo object has a maximum length requirement and the fieldValue object is greater than the maximum length the fieldValue object is invalid.
  7. If all these constraints are satisfied then the fieldValue is valid.

Specified by:
validate in interface FieldValidationRule
Overrides:
validate in class DefaultFieldValidationRule
Throws:
InvalidFieldValueException - if the Field value in invalid.


Generated on 8:41:50 AM June 06, 2005, © 1996-2005 Cafésoft LLC. All rights reserved.