|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.enhydra.barracuda.core.forms.AbstractFormValidator | +--org.enhydra.barracuda.core.forms.DefaultFormValidator | +--org.enhydra.barracuda.core.forms.validators.DigitValidator
This validator ensures that the value contains only digits tested against the field size length (len). If the value's length is not equal to the length or a character other than the numbers 0-9 is found, an exception will be throw.
This class can be used 3 ways
1) As a digit validator, confirming that only digits exist for the value. The field value "is not required", and will only be tested for digits when the field value "is not null". Use default constructor() or constructor(errorMessage) for this case.
2) As a digit/length validator where phoneNumber will default to false. This can be used to test set lengths of digits (credit cards, quantities, soc sec numbers etc.) The field value "is required". Use constructor(len) for this case.
3) As a phone number validator (domestic/international) where certain phone number rules apply. Use constructor(len, isDomesticPhone, errMessage) for this case.
Note: There is no current support for '.' or '-' in the value for phone numbers.
This class works very nicely where the input fields are separated into their respective types (i.e Separating a Domestic Phone Number into 3 'input type=text' boxes -- Area Code len=3, Prefix len = 3, and Number len =4) will permit easier implementation of the rules as more are added.
Rules:
--domesticPhone = true
if length = 3, then the value may not start with a zero (0)
--domesticPhone = false (international)
none
Field Summary | |
protected boolean |
domesticPhone
|
protected int |
len
|
protected boolean |
phoneNumber
|
protected boolean |
requireLength
|
Fields inherited from class org.enhydra.barracuda.core.forms.DefaultFormValidator |
localLogger, validators |
Constructor Summary | |
DigitValidator()
Public constructor. |
|
DigitValidator(int ilen)
Public constructor. |
|
DigitValidator(int ilen,
boolean idomesticPhone,
java.lang.String ierrmsg)
Public constructor. |
|
DigitValidator(int ilen,
java.lang.String ierrmsg)
Public constructor. |
|
DigitValidator(java.lang.String ierrmsg)
Public constructor. |
Method Summary | |
boolean |
isDomesticPhone()
Return true if this must be a domestic phone# |
void |
validateFormElement(java.lang.Object val,
FormElement element,
boolean deferExceptions)
Validate a FormElement to make see if the element equals() a given object |
Methods inherited from class org.enhydra.barracuda.core.forms.DefaultFormValidator |
addValidator, getValidators, removeValidator, validate, validateForm, validateFormElement |
Methods inherited from class org.enhydra.barracuda.core.forms.AbstractFormValidator |
generateException, getErrorMessage, isNull, setErrorMessage |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected int len
protected boolean requireLength
protected boolean phoneNumber
protected boolean domesticPhone
Constructor Detail |
public DigitValidator()
public DigitValidator(java.lang.String ierrmsg)
public DigitValidator(int ilen)
public DigitValidator(int ilen, java.lang.String ierrmsg)
public DigitValidator(int ilen, boolean idomesticPhone, java.lang.String ierrmsg)
Method Detail |
public boolean isDomesticPhone()
public void validateFormElement(java.lang.Object val, FormElement element, boolean deferExceptions) throws ValidationException
validateFormElement
in class DefaultFormValidator
element
- the form element to be validateddeferExceptions
- do we want to deferValidation exceptions
and attempt to validate all elements so that we can process
all the exceptions at onceval
- the actual value to be validated
ValidationException
- if the element is not valid
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |