com.smartgwt.client.widgets.form.validator

## Class CustomValidator

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

- All Implemented Interfaces:
    com.google.gwt.event.shared.HasHandlers

      public abstract class CustomValidator
      extends Validator

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.Integer` | `colNum`
    `protected DataSourceField` | `dataSourceField`
    `protected DynamicForm` | `dynamicForm`
    `protected FormItem` | `formItem`
    `protected ListGrid` | `listGrid`
    `protected ListGridField` | `listGridField`
    `protected Record` | `record`
    `protected java.lang.Object` | `resultingValue`
    `protected java.lang.Integer` | `rowNum`
    `protected java.util.Map` | `validatorProperties`

    - ### Fields inherited from class com.smartgwt.client.core.DataClass

      `factoryCreated, factoryProperties`

    - ### Fields inherited from class com.smartgwt.client.core.JsObject

      `jsObj`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CustomValidator()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract boolean` | `condition(java.lang.Object value)` Add custom validation logic by overriding this method.
    `java.lang.Integer` | `getColNum()` The column number of the cell currently being validated, if the component being validated is a ListGrid.
    `DataSourceField` | `getDataSourceField()` DataSourceField on which this validator was declared.
    `DynamicForm` | `getDynamicForm()` DynamicForm currently being validated.
    `FormItem` | `getFormItem()` FormItem on which this validator was declared.
    `ListGrid` | `getListGrid()` ListGrid currently being validated.
    `ListGridField` | `getListGridField()` ListGridField on which this validator was declared.
    `Record` | `getRecord()`
    `java.lang.Integer` | `getRowNum()` The row number of the cell currently being validated, if the component being validated is a ListGrid.
    `java.util.Map` | `getValidatorProperties()` Return the properties of validator that is defined on the DataSourceField.
    `protected void` | `setResultingValue(java.lang.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, create, getApplyWhen, getCheckComponentData, getClientOnly, getCondition, getDependentFields, getOrCreateRef, getStopIfFalse, getStopOnError, getType, getTypeAsString, getValidateOnChange, setApplyWhen, setCheckComponentData, setClientOnly, setCondition, setDependentFields, setErrorMessage, setStopIfFalse, setStopOnError, setType, setType, setValidateOnChange`

    - ### Methods inherited from class com.smartgwt.client.core.DataClass

      `applyFactoryProperties, doAddHandler, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsDoubleArray, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsIntArray, getAttributeAsJavaScriptObject, getAttributeAsLong, getAttributeAsMap, getAttributeAsObject, getAttributeAsRecord, getAttributeAsString, getAttributeAsStringArray, getAttributes, getHandlerCount, isFactoryCreated, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributeAsJavaObject, setFactoryCreated`

    - ### Methods inherited from class com.smartgwt.client.core.JsObject

      `equals, getJsObj, hashCode, isCreated, setJavaScriptObject, setJsObj`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### formItem

          protected FormItem formItem

    - #### dataSourceField

          protected DataSourceField dataSourceField

    - #### listGridField

          protected ListGridField listGridField

    - #### record

          protected Record record

    - #### validatorProperties

          protected java.util.Map validatorProperties

    - #### resultingValue

          protected java.lang.Object resultingValue

    - #### dynamicForm

          protected DynamicForm dynamicForm

    - #### listGrid

          protected ListGrid listGrid

    - #### rowNum

          protected java.lang.Integer rowNum

    - #### colNum

          protected java.lang.Integer colNum

  - ### Constructor Detail

    - #### CustomValidator

          public CustomValidator()

  - ### Method Detail

    - #### condition

          protected abstract boolean condition(java.lang.Object value)

      Add custom validation logic by overriding this method. Access to the FormItem, ListGridField or DataSourceField on which the validator was declared can be obtained by the `getFormItem()`, `getListGridField()` and `getDataSourceField()` methods respectively. The field values for the record being validated can be obtained by calling `getRecord()`. The component being validated can be obtained by calling `getListGrid()` or `getDynamicForm()`. If the component being validated is a ListGrid, the row and column numbers identifying the cell being validated are accessible with the `getRowNum()` and `getColNum()` methods.
      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 ListGridField or DataSourceField, in which case `getListGridField()` or `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.

    - #### getListGridField

          public ListGridField getListGridField()

      ListGridField on which this validator was declared. May be null if the item is a FormItem or DataSourceField, in which case `getFormItem()` or `getDataSourceField()` should be called.
      Returns:
        ListGridField 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 or ListGridField, in which case `getFormItem()` or `getListGridField()` should be called.
      Returns:
        DataSourceField on which this validator was declared.

    - #### getListGrid

          public ListGrid getListGrid()

      ListGrid currently being validated. May be null if the component being validated is a DynamicForm, in which case `getDynamicForm()` should be called.
      Returns:
        ListGrid currently being validated

    - #### getDynamicForm

          public DynamicForm getDynamicForm()

      DynamicForm currently being validated. May be null if the component being validated is a ListGrid, in which case `getListGrid()` should be called.
      Returns:
        DynamicForm currently being validated

    - #### getRowNum

          public java.lang.Integer getRowNum()

      The row number of the cell currently being validated, if the component being validated is a ListGrid. If the component being validated is a DynamicForm, this will be null
      Returns:
        the row number of the cell currently being validated, or null if the component is not a ListGrid

    - #### getColNum

          public java.lang.Integer getColNum()

      The column number of the cell currently being validated, if the component being validated is a ListGrid. If the component being validated is a DynamicForm, this will be null
      Returns:
        the column number of the cell currently being validated, or null if the component is not a ListGrid

    - #### getValidatorProperties

          public java.util.Map getValidatorProperties()

      Return the properties of validator that is defined on the DataSourceField.
      Returns:
        the validator properties

    - #### setResultingValue

          protected void setResultingValue(java.lang.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