com.smartgwt.client.widgets.form.validator
Class CustomValidator

java.lang.Object
  extended by com.smartgwt.client.core.JsObject
      extended by com.smartgwt.client.core.DataClass
          extended by com.smartgwt.client.widgets.form.validator.Validator
              extended by com.smartgwt.client.widgets.form.validator.CustomValidator

public abstract class CustomValidator
extends Validator


Field Summary
protected  DataSourceField dataSourceField
           
protected  FormItem formItem
           
protected  Record record
           
protected  Object resultingValue
           
protected  Map validatorProperties
           
 
Fields inherited from class com.smartgwt.client.core.JsObject
jsObj
 
Constructor Summary
CustomValidator()
           
 
Method Summary
protected abstract  boolean condition(Object value)
          Add custom validation logic by overriding this method.
 DataSourceField getDataSourceField()
          DataSourceField on which this validator was declared.
 FormItem getFormItem()
          FormItem on which this validator was declared.
 Record getRecord()
           
 Map getValidatorProperties()
          Return the properties of validator that is defined on the DataSourceField.
protected  void setResultingValue(Object resultingValue)
          To transform the incoming value that is validated into a different value or format set this property from Validator.condition() to the desired value.
 
Methods inherited from class com.smartgwt.client.widgets.form.validator.Validator
addValidatorDefinition, convertToValidatorArray, getClientOnly, getDependentFields, getOrCreateRef, getStopIfFalse, getStopOnError, getType, getTypeAsString, getValidateOnChange, setClientOnly, setDependentFields, setErrorMessage, setStopIfFalse, setStopOnError, setType, setType, setValidateOnChange
 
Methods inherited from class com.smartgwt.client.core.DataClass
doAddHandler, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsDoubleArray, getAttributeAsFloat, getAttributeAsInt, getAttributeAsIntArray, getAttributeAsJavaScriptObject, getAttributeAsLong, getAttributeAsMap, getAttributeAsObject, getAttributeAsRecord, getAttributeAsString, getAttributeAsStringArray, getAttributes, getHandlerCount, getJsObj, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute
 
Methods inherited from class com.smartgwt.client.core.JsObject
isCreated, setJsObj
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

formItem

protected FormItem formItem

dataSourceField

protected DataSourceField dataSourceField

record

protected Record record

validatorProperties

protected Map validatorProperties

resultingValue

protected Object resultingValue
Constructor Detail

CustomValidator

public CustomValidator()
Method Detail

condition

protected abstract boolean condition(Object value)
Add custom validation logic by overriding this method. Access to the FormItem or DataSourceField on which the validator was declared can be obtained by the getFormItem() and getDataSourceField() methods respectively and the field values for record being validated can be obtained by calling getRecord().

Parameters:
value - value to validate
Returns:
true if valid

getFormItem

public FormItem getFormItem()
FormItem on which this validator was declared. May be null if the item is a DataSourceField in which case getDataSourceField() should be called. NOTE: FormItem will not be available during a save performed without a form (eg programmatic save) or if the field.

Returns:
FormItem on which this validator was declared.

getDataSourceField

public DataSourceField getDataSourceField()
DataSourceField on which this validator was declared. May be null if the item is a FormItem in which case getFormItem() should be called.

Returns:
DataSourceField on which this validator was declared.

getValidatorProperties

public Map getValidatorProperties()
Return the properties of validator that is defined on the DataSourceField.

Returns:
the validator properties

setResultingValue

protected void setResultingValue(Object resultingValue)
To transform the incoming value that is validated into a different value or format set this property from Validator.condition() to the desired value.

Parameters:
resultingValue - the resulting value

getRecord

public Record getRecord()
Returns:
field values for record being validated