Class CustomValidator

All Implemented Interfaces:
HasHandlers

public abstract class CustomValidator extends Validator
  • Field Details

    • formItem

      protected FormItem formItem
    • dataSourceField

      protected DataSourceField dataSourceField
    • listGridField

      protected ListGridField listGridField
    • record

      protected Record record
    • validatorProperties

      protected Map validatorProperties
    • resultingValue

      protected Object resultingValue
    • dynamicForm

      protected DynamicForm dynamicForm
    • listGrid

      protected ListGrid listGrid
    • rowNum

      protected Integer rowNum
    • colNum

      protected Integer colNum
  • Constructor Details

    • CustomValidator

      public CustomValidator()
  • Method Details

    • condition

      protected abstract boolean condition(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 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 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 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