org.jscience.sociology.forms
Interface FieldValidator

All Superinterfaces:
java.io.Serializable

public interface FieldValidator
extends java.io.Serializable

Defines the interface for classes that will play the role of value validators for org.jscience.sociology.forms.TextBox and org.jscience.sociology.forms.PasswordBox fields. The criteria of validation will be implemented through getErrorMessage() method of this interface. A class of type TextBox will register one or more FieldValidator objects via addFieldValidator() method.

The following shows how to add a FieldValidator to a field in forms.xml:

 <field name="field name"
   type="org.jscience.sociology.forms.TextBox">
   ...............
   ...............
   <field-validator>
      FieldValidator object name
   </field-validator>
 </field>
 

A FieldValidator object will normally be shared by all client threads of one or even more forms, therefore the implementation has to take care of possible synchronization issues.

See Also:
TextBox, PasswordBox

Method Summary
 java.lang.String getErrorMessage(java.lang.String value)
          Gets the error message resulting from the validation.
 

Method Detail

getErrorMessage

java.lang.String getErrorMessage(java.lang.String value)
Gets the error message resulting from the validation. If the supplied value passes the test (or tests) implemented by this method, an empty string must be returned.

Parameters:
value - the value to be tested.
Returns:
the error message or an empty string in case the value has successfully passed the test.