Validation methods for DataTables Editor fields. All of the methods defined in this class return a function that can be used by Field instance's Field.Validator method.

Each method may define its own parameters that configure how the formatter operates. For example the minLen validator takes information on the minimum length of value to accept.

Additionally each method can optionally take a ValidationOptions instance that controls common validation options and error messages.

The validation functions return true for valid data and a string for invalid data, with the string being the error message.

Export

Hierarchy

  • Validate

Constructors

Properties

Host: typeof default = ValidationHost
Options: typeof default = ValidationOptions

Methods

  • Basic validation - this is used to perform the validation provided by the validation options only. If the validation options pass (e.g. required, empty and optional) then the validation will pass regardless of the actual value.

    Static

    Returns

    Configured validation function

    Parameters

    • Optional cfg: default = null

      Validation options

    Returns IValidator

  • Validate an input as a boolean value.

    Static

    Returns

    Configured validation function

    Parameters

    • Optional cfg: default = null

      Validation options

    Returns IValidator

  • Check that a valid date input is given. Uses MomentJS

    Static

    Returns

    Configured validation function

    Parameters

    • format: string

      MomentJS date format

    • Optional locale: string = null

      MomentJS locale

    • Optional cfg: default = null

      Validation options

    Returns IValidator

  • Check that the given value is unique in the database

    Static

    Returns

    Configured validation function

    Parameters

    • Optional cfg: default = null

      Validation options

    • Optional column: string = null

      Column name to use to check as a unique value. If not given the host field's database column name is used

    • Optional table: string = null

      Table to check that this value is uniquely valid on. If not given the host Editor's table name is used

    • Optional db: Knex<any, any[]> = null

      Database connection. If not given the host Editor's database connection is used

    Returns IValidator

  • Check that the given value is a value that is available in a database - i.e. a join primary key. This will attempt to automatically use the table name and value column from the field's Options method (under the assumption that it will typically be used with a joined field), but the table and field can also be specified via the options.

    Static

    Returns

    Configured validation function

    Parameters

    • Optional cfg: default = null

      Validation options

    • Optional column: string = null

      Column name to use to check as a unique value. If not given the host field's database column name is used

    • Optional table: string = null

      Table to check that this value is uniquely valid on. If not given the host Editor's table name is used

    • Optional db: Knex<any, any[]> = null

      Database connection. If not given the host Editor's database connection is used

    • values: any[] = []

    Returns IValidator

  • Validate an input as an e-mail address.

    Static

    Returns

    Configured validation function

    Parameters

    • Optional cfg: default = null

      Validation options

    Returns IValidator

  • Check that the uploaded file has a given extension

    Static

    Returns

    Configured validation function

    Parameters

    • extns: string[]

      Allowed extensions

    • msg: string

      Error message to return if not valid

    Returns IFileValidator

  • Check that the uploaded file is equal or less than a given size.

    Static

    Returns

    Configured validation function

    Parameters

    • size: number

      Max file size in bytes

    • msg: string

    Returns IFileValidator

  • Validate as an IP address.

    Static

    Returns

    Configured validation function

    Parameters

    • Optional cfg: default = null

      Validation options

    Returns IValidator

  • Validate a string is less or equal to a maximum length.

    Static

    Returns

    Configured validation function

    Parameters

    • max: number

      Maximum length

    • Optional cfg: default = null

      Validation options

    Returns IValidator

  • Check for a numeric input and that it is less than a given value.

    Static

    Returns

    Configured validation function

    Parameters

    • max: number

      Maximum value

    • Optional decimal: string = '.'

      Character to use as the decimal place

    • Optional cfg: default = null

      Validation options

    Returns IValidator

  • Validate a string has a minimum length.

    Static

    Returns

    Configured validation function

    Parameters

    • min: number

      Minimum length

    • Optional cfg: default = null

      Validation options

    Returns IValidator

  • Require a string with a certain minimum or maximum number of characters.

    Static

    Returns

    Configured validation function

    Parameters

    • min: number

      Minimum length

    • max: number

      Maximum length

    • Optional cfg: default = null

      Validation options

    Returns IValidator

  • Check for a numeric input and that it is in between two given values.

    Static

    Returns

    Configured validation function

    Parameters

    • min: number

      Minimum value

    • max: number

      Maximum value

    • Optional decimal: string = '.'

      Character to use as the decimal place

    • Optional cfg: default = null

      Validation options

    Returns IValidator

  • Check for a numeric input and that it is greater than a given value.

    Static

    Returns

    Configured validation function

    Parameters

    • min: number

      Minimum value

    • Optional decimal: string = '.'

      Character to use as the decimal place

    • Optional cfg: default = null

      Validation options

    Returns IValidator

  • Require a maximum value of the number of options / values submitted in an array

    Static

    Returns

    Configured validation function

    Parameters

    • size: number

      Max array size required to be valid

    • msg: string

      Error message

    Returns IMjoinValidator

  • Require a minimum value of the number of options / values submitted in an array

    Static

    Returns

    Configured validation function

    Parameters

    • size: number

      Min array size required to be valid

    • msg: string

      Error message

    Returns IMjoinValidator

  • Ensure that the submitted string does not contain HTML tags

    Static

    Returns

    Configured validation function

    Parameters

    • Optional cfg: default = null

      Validation options

    Returns IValidator

  • No validation - all inputs are valid

    Static

    Returns

    Configured validation function

    Parameters

    • Optional cfg: default = null

      Validation options

    Returns IValidator

  • Optional field, but if given there must be a non-empty value

    Static

    Returns

    Configured validation function

    Parameters

    • Optional cfg: default = null

      Validation options

    Returns IValidator

  • Check that any input is numeric.

    Static

    Returns

    Configured validation function

    Parameters

    • Optional decimal: string = '.'

      Character to use as the decimal place

    • Optional cfg: default = null

      Validation options

    Returns IValidator

  • Required field - there must be a value and it must be a non-empty value

    Static

    Returns

    Configured validation function

    Parameters

    • Optional cfg: default = null

      Validation options

    Returns IValidator

  • Validate as a URL.

    Static

    Returns

    Configured validation function

    Parameters

    • Optional cfg: default = null

      Validation options

    Returns IValidator

  • Confirm that the value submitted is in a list of allowable values

    Static

    Returns

    Configured validation function

    Parameters

    • values: any[]

      List of values that are valid

    • Optional cfg: default = null

      Validation options

    Returns IValidator

  • Check if string could contain an XSS attack string

    Static

    Returns

    Configured validation function

    Parameters

    • Optional cfg: default = null

      Validation options

    Returns IValidator

Generated using TypeDoc