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

-     public abstract class CustomValidator
      extends Validator

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected DataSourceField` | `dataSourceField`
    `protected FormItem` | `formItem`
    `protected Record` | `record`
    `protected java.lang.Object` | `resultingValue`
    `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

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract boolean` | `condition(java.lang.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()`
    `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, 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

      `applyFactoryProperties, doAddHandler, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsDoubleArray, 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

    - #### record

          protected Record record

    - #### validatorProperties

          protected java.util.Map validatorProperties

    - #### resultingValue

          protected java.lang.Object resultingValue

  - ### 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 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 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