Package com.smartgwt.client.types

# Enum ValidatorType

java.lang.Object
java.lang.Enum<ValidatorType>
com.smartgwt.client.types.ValidatorType

All Implemented Interfaces:
  `ValueEnum`, `Serializable`, `Comparable<ValidatorType>`, `Constable`

public enum ValidatorType extends Enum<ValidatorType> implements ValueEnum
Used to name a validator or reference a standard, built-in `Validator` - see list below.

To make use of a standard validator type for a field in a DataSource, or DynamicForm instance, specify the `validators` property to an array containing a validator definition where the `type` property is set to the appropriate type.

A custom error message can be specified for any validator type by setting the `errorMessage` property on the validator definition object, and some validator types make use of additional properties on the validator definition object such as `max` or `min`.

For example, to use the `integerRange` validator type:
`field:{
validators:[
{type:"integerRange", min:1, max:100}
]
}`

Custom validators can be reused on the client by adding them to the global validator list, via the `Validator.addValidatorDefinition()` method.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class java.lang.Enum

  `Enum.EnumDesc<E extends Enum<E>>`

- ## Enum Constant Summary

  Enum Constants
  Enum Constant
  Description
  `CONTAINS`
  Determine whether a string value contains some substring specified via `validator.substring`.
  `CUSTOM`
  Custom client-side validator.
  `DATERANGE`
  Tests whether the value for a date field is within the range specified.
  `DOESNTCONTAIN`
  Determine whether a string value does not contain some substring specified via `validator.substring`.
  `EQUALS`
  Tests whether the value for this field matches some value specified via `value`.
  `FLOATLIMIT`
  Validate a field as a valid floating point value within a value range.
  `FLOATPRECISION`
  Tests whether the value for this field is a floating point number with the appropriate number of decimal places - specified in `validator.precision` If the value is of higher precision and `validator.roundToPrecision` is specified, the value will be rounded to the specified number of decimal places and validation will pass, otherwise validation will fail.
  `FLOATRANGE`
  Tests whether the value for this field is a floating point number within the range specified.
  `HASRELATEDRECORD`
  Returns true if the record implied by a relation exists.
  `INSET`
  Tests whether the value for this field matches any value from an arbitrary list of acceptable values.
  `INTEGERRANGE`
  Tests whether the value for this field is a whole number within the range specified.
  `ISBOOLEAN`
  Validation will fail if this field is non-empty and has a non-boolean value.
  `ISFLOAT`
  Tests whether the value for this field is a valid floating point number.
  `ISFUNCTION`
  Tests whether the value for this field is a valid expression or function; if it is valid, creates a `stringMethod` object with the value and set the resultingValue to the StringMethod.
  `ISINTEGER`
  Tests whether the value for this field is a whole number.
  `ISONEOF`
  Tests whether the value for this field matches any value from an arbitrary list of acceptable values.
  `ISSTRING`
  Validation will fail if the value is not a string value.
  `ISUNIQUE`
  Returns true if the value for this field is unique.
  `LENGTHRANGE`
  This validator type applies to string values only.
  `MASK`
  Validate against a regular expression mask, specified as `validator.mask`.
  `MATCHESFIELD`
  Tests whether the value for this field matches the value of some other field.
  `MAXFILESIZE`
  This validator type is not for direct usage, instead `DataSourceField.maxFileSize` can be set and `maxFileSize` validator will be added automatically.
  `NOTEQUAL`
  Tests whether the value for this field does not match some value specified via `value`.
  `NOTINSET`
  Tests whether the value for this field does not match any value from an arbitrary list of unacceptable values.
  `REGEXP`
  `regexp` type validators will determine whether the value specified matches a given regular expression.
  `REQUIRED`
  A non-empty value is required for this field to pass validation.
  `REQUIREDIF`
  RequiredIf type validators should be specified with an `expression` property set to a `stringMethod`, which takes four parameters: item - the DynamicForm item on which the error occurred (may be null) validator - a pointer to the validator object value - the value of the field in question record - the "record" object - the set of values being edited by the widget When validation is performed, the expression will be evaluated (or executed).
  `SERVERCUSTOM`
  Custom server-side validator that either evaluates the Velocity expression provided in `serverCondition` (see Velocity Expression Example) or makes DMI call to `serverObject` to evaluate condition (see DMI Validation Example).
  `SUBSTRINGCOUNT`
  Determine whether a string value contains some substring multiple times.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getValue()`
  `static ValidatorType`
  `valueOf(String name)`
  Returns the enum constant of this type with the specified name.
  `static ValidatorType[]`
  `values()`
  Returns an array containing the constants of this enum type, in the order they are declared.

  ### Methods inherited from class java.lang.Enum

  `clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

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

  `getClass, notify, notifyAll, wait, wait, wait`

- ## Enum Constant Details

  - ### ISBOOLEAN

    public static final ValidatorType ISBOOLEAN
    Validation will fail if this field is non-empty and has a non-boolean value.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "isBoolean".

  - ### ISSTRING

    public static final ValidatorType ISSTRING
    Validation will fail if the value is not a string value.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "isString".

  - ### ISINTEGER

    public static final ValidatorType ISINTEGER
    Tests whether the value for this field is a whole number. If `validator.convertToInteger` is true, float values will be converted into integers and validation will succeed.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "isInteger".

  - ### ISFLOAT

    public static final ValidatorType ISFLOAT
    Tests whether the value for this field is a valid floating point number.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "isFloat".

  - ### ISFUNCTION

    public static final ValidatorType ISFUNCTION
    Tests whether the value for this field is a valid expression or function; if it is valid, creates a `stringMethod` object with the value and set the resultingValue to the StringMethod.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "isFunction".

  - ### REQUIREDIF

    public static final ValidatorType REQUIREDIF
    RequiredIf type validators should be specified with an `expression` property set to a `stringMethod`, which takes four parameters:
    - item - the DynamicForm item on which the error occurred (may be null)
    - validator - a pointer to the validator object
    - value - the value of the field in question
    - record - the "record" object - the set of values being edited by the widget
    When validation is performed, the expression will be evaluated (or executed). If it returns `true`, the field will be treated as a required field, so validation will fail if the field has no value, or, in the case of a `FileItem` or `UploadItem` and if client-side validation is supported by the browser, if no file is selected for upload or the selected file is empty.

    To allow server-side enforcement, a `required` validator can be used instead. With the exception of "binary" fields, conditional criteria can be specified with the `applyWhen` property.

    See Conditionally Required Example.

    Moreover, the expression provided needs to be in JavaScript, so to use this API, you should be familiar with JavaScript and Smart GWT APIs. A pure-Java alternative is to add a `RequiredIfValidator` on the DynamicForm or ListGrid where validation is required.

    NOTE: A requiredIf validator cannot be used to guarantee that a non-empty file is uploaded. The user's browser might not support client-side file validation. Using a requiredIf validator on a "binary" field may be appropriate in scenarios where the application does not technically require a non-empty file to be uploaded by the user. For example, in a bug tracking application, a file upload may be required if the "Have a test case?" checkbox is checked, but the value of the "Have a test case?" checkbox is not actually saved by the application; instead, whether the user is providing a test case is inferred by whether a non-empty test case file was uploaded.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "requiredIf".

  - ### MATCHESFIELD

    public static final ValidatorType MATCHESFIELD
    Tests whether the value for this field matches the value of some other field. The field to compare against is specified via the `otherField` property on the validator object (should be set to a field name).

    See Match Value Example.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "matchesField".

  - ### EQUALS

    public static final ValidatorType EQUALS
    Tests whether the value for this field matches some value specified via `value`.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "equals".

  - ### NOTEQUAL

    public static final ValidatorType NOTEQUAL
    Tests whether the value for this field does not match some value specified via `value`.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "notEqual".

  - ### ISONEOF

    public static final ValidatorType ISONEOF
    Tests whether the value for this field matches any value from an arbitrary list of acceptable values. The set of acceptable values is specified via the `list` property on the validator, which should be set to an array of values. If validator.list is not supplied, the valueMap for the field will be used. If there is no valueMap, not providing validator.list is an error.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "isOneOf".

  - ### INSET

    public static final ValidatorType INSET
    Tests whether the value for this field matches any value from an arbitrary list of acceptable values. The set of acceptable values is specified via the `list` property on the validator, which should be set to an array of values. If validator.list is not supplied, the valueMap for the field will be used. If there is no valueMap, not providing validator.list is an error.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "inSet".

  - ### NOTINSET

    public static final ValidatorType NOTINSET
    Tests whether the value for this field does not match any value from an arbitrary list of unacceptable values. The set of unacceptable values is specified via the `list` property on the validator, which should be set to an array of values. Not providing validator.list is an error.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "notInSet".

  - ### INTEGERRANGE

    public static final ValidatorType INTEGERRANGE
    Tests whether the value for this field is a whole number within the range specified. The `max` and `min` properties on the validator are used to determine the acceptable range, inclusive. To specify the range as exclusive of the min/mix values, set `exclusive` to `true`.

    See Built-ins Example.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "integerRange".

  - ### LENGTHRANGE

    public static final ValidatorType LENGTHRANGE
    This validator type applies to string values only. If the value is a string value validation will fail if the string's length falls outside the range specified by `validator.max` and `validator.min`.

    Note that non-string values will always pass validation by this validator type.

    Note that the `errorMessage` for this validator will be evaluated as a dynamicString - text within `${...}` will be evaluated as JS code when the message is displayed, with `max` and `min` available as variables mapped to `validator.max` and `validator.min`.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "lengthRange".

  - ### CONTAINS

    public static final ValidatorType CONTAINS
    Determine whether a string value contains some substring specified via `validator.substring`.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "contains".

  - ### DOESNTCONTAIN

    public static final ValidatorType DOESNTCONTAIN
    Determine whether a string value does not contain some substring specified via `validator.substring`.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "doesntContain".

  - ### SUBSTRINGCOUNT

    public static final ValidatorType SUBSTRINGCOUNT
    Determine whether a string value contains some substring multiple times. The substring to check for is specified via `validator.substring`. The `validator.operator` property allows you to specify how to test the number of substring occurrences. Valid values for this property are `==`, `!=`, `<`, `<=`, `>`, `>=`.

    The number of matches to check for is specified via `validator.count`.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "substringCount".

  - ### REGEXP

    public static final ValidatorType REGEXP
    `regexp` type validators will determine whether the value specified matches a given regular expression. The expression should be specified on the `validator` object as the `expression` property.

    See Regular Expression Example.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "regexp".

  - ### MASK

    public static final ValidatorType MASK
    Validate against a regular expression mask, specified as `validator.mask`. If validation is successful a transformation can also be specified via the `validator.transformTo` property. This should be set to a string in the standard format for string replacement via the native JavaScript `replace()` method.

    See Value Transform Example.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "mask".

  - ### DATERANGE

    public static final ValidatorType DATERANGE
    Tests whether the value for a date field is within the range specified. Range is inclusive, and is specified via `validator.min` and `validator.max`, which should be specified in XML Schema date format or as a live JavaScript Date object (for client-only validators only). To specify the range as exclusive of the min/mix values, set `exclusive` to `true`.

    Note that the `errorMessage` for this validator will be evaluated as a dynamicString - text within `${...}` will be evaluated as JS code when the message is displayed, with `max` and `min` available as variables mapped to `validator.max` and `validator.min`.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "dateRange".

  - ### FLOATLIMIT

    public static final ValidatorType FLOATLIMIT
    Validate a field as a valid floating point value within a value range. Range is specified via `validator.min` and `validator.max`. Also checks precision, specified as number of decimal places in `validator.precision`. If `validator.roundToPrecision` is set a value that doesn't match the specified number of decimal places will be rounded to the nearest value that does.

    For backwards compatibility only. Use "floatRange" and/or "floatPrecision" instead.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "floatLimit".

  - ### FLOATRANGE

    public static final ValidatorType FLOATRANGE
    Tests whether the value for this field is a floating point number within the range specified. The `max` and `min` properties on the validator are used to determine the acceptable range, inclusive. To specify the range as exclusive of the min/mix values, set `exclusive` to `true`.

    Note that the `errorMessage` for this validator will be evaluated as a dynamicString - text within `${...}` will be evaluated as JS code when the message is displayed, with `max` and `min` available as variables mapped to `validator.max` and `validator.min`.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "floatRange".

  - ### FLOATPRECISION

    public static final ValidatorType FLOATPRECISION
    Tests whether the value for this field is a floating point number with the appropriate number of decimal places - specified in `validator.precision` If the value is of higher precision and `validator.roundToPrecision` is specified, the value will be rounded to the specified number of decimal places and validation will pass, otherwise validation will fail.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "floatPrecision".

  - ### REQUIRED

    public static final ValidatorType REQUIRED
    A non-empty value is required for this field to pass validation.

    In the case of a "binary" field, a non-empty file must be uploaded.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "required".

  - ### ISUNIQUE

    public static final ValidatorType ISUNIQUE
    Returns true if the value for this field is unique. The uniqueness check is performed across the whole DataSource unless you specify property `validator.criteriaFields` as a comma-separated string of field names; in that case, the uniqueness check is done in the context of those extra criteria, allowing you to check, for example, whether an employee number is unique for the department and location found on the record being validated. By default the uniqueness check is not case sensitive but this can be controlled through the `caseSensitive` attribute. You can specify the `operation` to use for the uniqueness check with the `operationId` attribute.

    Validators of this type have requiresServer set to `true` and do not run on the client, unless all of the following are true:

    - The validation is run in the context of a DataBoundComponent or ValuesManager bound to some DataSource.
    - The DataSource is either clientOnly:true or cacheAllData: true and all data is loaded
    - The item is made available to the validator. Note that the item is not be available during a save performed without a form (eg programmatic save), or if the field is not available in the form.

    Note when isUnique validator is executed as part of validation process during update operation, it will perform uniqueness check only for single row updates. If update targets `multiple records`, then isUnique validator will be skipped. If uniqueness check is needed when updating multiple records, consider using `custom DMI` approach to add this check manually.

    See uniqueCheckValidation.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "isUnique".

  - ### HASRELATEDRECORD

    public static final ValidatorType HASRELATEDRECORD
    Returns true if the record implied by a relation exists. The relation can be derived automatically from the `DataSourceField.foreignKey` attribute of the field being validated, or you can specify it manually via `validator.relatedDataSource` and `validator.relatedField`.

    You can specify at DataSource level that this validator should be automatically applied to all fields that specify a `foreignKey` - see `DataSource.validateRelatedRecords`.

    By default the uniqueness check is not case sensitive but this can be controlled through the `caseSensitive` attribute.

    Validators of this type have requiresServer set to `true` and do not run on the client.

    Note that this validation is generally unnecessary for data coming from a UI. The typical UI uses a `SelectItem` or `ComboBoxItem` with an `optionDataSource` for user entry, such that the user can't accidentally enter a related record if that doesn't exist, and a typical SQL schema will include constraints that prevent a bad insert if the user attempts to circumvent the UI. The primary purpose of declaring this validation explicitly is to provide clear, friendly error messages for use cases such as `BatchUploader`, where values aren't individually chosen by the user. See also the example Related Records.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "hasRelatedRecord".

  - ### MAXFILESIZE

    public static final ValidatorType MAXFILESIZE
    This validator type is not for direct usage, instead `DataSourceField.maxFileSize` can be set and `maxFileSize` validator will be added automatically. Use `maxFileSizeExceededMessage` to customize validation error message.

    In supported browsers (Internet Explorer 10+, Chrome, Firefox, Safari 6+, Opera 11.1+), returns `true` if the file(s) selected by the user are not larger than the field's `DataSourceField.maxFileSize`. If not supported by the browser, the validator will always return `true`.

    Note that server-side enforcement of the `maxFileSize` is always required because the user's browser might not support client-side file size checks. Also, any client-side check can be bypassed by a malicious user.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "maxFileSize".

  - ### CUSTOM

    public static final ValidatorType CUSTOM
    Custom client-side validator. Use by creating a subclass of Custom.CustomValidator and implementing the `condition` method.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "custom".

  - ### SERVERCUSTOM

    public static final ValidatorType SERVERCUSTOM
    Custom server-side validator that either evaluates the Velocity expression provided in `serverCondition` (see Velocity Expression Example) or makes DMI call to `serverObject` to evaluate condition (see DMI Validation Example).

    Validators of this type have requiresServer set to `true` and do not run on the client.

    If this enumerated value is used in a `Component XML` file or server-side DataSource descriptor (.ds.xml file), use the value "serverCustom".

- ## Method Details

  - ### values

    public static ValidatorType[] values()
    Returns an array containing the constants of this enum type, in the order they are declared.
    Returns:
      an array containing the constants of this enum type, in the order they are declared

  - ### valueOf

    public static ValidatorType valueOf(String name)
    Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
    Parameters:
      `name` - the name of the enum constant to be returned.
    Returns:
      the enum constant with the specified name
    Throws:
      `IllegalArgumentException` - if this enum type has no constant with the specified name
      `NullPointerException` - if the argument is null

  - ### getValue

    public String getValue()
    Specified by:
      `getValue` in interface `ValueEnum`