Options
All
  • Public
  • Public/Protected
  • All
Menu

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 {@link 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

Index

Constructors

Properties

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

Methods

  • basic(cfg?: default): IValidator
  • 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

    Parameters

    • cfg: default = null

    Returns IValidator

    Configured validation function

  • boolean(cfg?: default): IValidator
  • Validate an input as a boolean value.

    static

    Parameters

    • cfg: default = null

    Returns IValidator

    Configured validation function

  • dateFormat(format: string, locale?: string, cfg?: default): IValidator
  • Check that a valid date input is given. Uses MomentJS

    static

    Parameters

    • format: string

      MomentJS date format

    • locale: string = null
    • cfg: default = null

    Returns IValidator

    Configured validation function

  • dbUnique(cfg?: default, column?: string, table?: string, db?: Knex<any, any[]>): IValidator
  • Check that the given value is unique in the database

    static

    Parameters

    • cfg: default = null
    • column: string = null
    • table: string = null
    • db: Knex<any, any[]> = null

    Returns IValidator

    Configured validation function

  • dbValues(cfg?: default, column?: string, table?: string, db?: Knex<any, any[]>, values?: any[]): 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

    Parameters

    • cfg: default = null
    • column: string = null
    • table: string = null
    • db: Knex<any, any[]> = null
    • values: any[] = []

    Returns IValidator

    Configured validation function

  • email(cfg?: default): IValidator
  • Validate an input as an e-mail address.

    static

    Parameters

    • cfg: default = null

    Returns IValidator

    Configured validation function

  • fileExtensions(extns: string[], msg: string): IFileValidator
  • Check that the uploaded file has a given extension

    static

    Parameters

    • extns: string[]

      Allowed extensions

    • msg: string

      Error message to return if not valid

    Returns IFileValidator

    Configured validation function

  • fileSize(size: number, msg: string): IFileValidator
  • Check that the uploaded file is equal or less than a given size.

    static

    Parameters

    • size: number

      Max file size in bytes

    • msg: string

    Returns IFileValidator

    Configured validation function

  • ip(cfg?: default): IValidator
  • Validate as an IP address.

    static

    Parameters

    • cfg: default = null

    Returns IValidator

    Configured validation function

  • maxLen(max: number, cfg?: default): IValidator
  • Validate a string is less or equal to a maximum length.

    static

    Parameters

    • max: number

      Maximum length

    • cfg: default = null

    Returns IValidator

    Configured validation function

  • maxNum(max: number, decimal?: string, cfg?: default): IValidator
  • Check for a numeric input and that it is less than a given value.

    static

    Parameters

    • max: number

      Maximum value

    • decimal: string = '.'
    • cfg: default = null

    Returns IValidator

    Configured validation function

  • minLen(min: number, cfg?: default): IValidator
  • Validate a string has a minimum length.

    static

    Parameters

    • min: number

      Minimum length

    • cfg: default = null

    Returns IValidator

    Configured validation function

  • minMaxLen(min: number, max: number, cfg?: default): IValidator
  • Require a string with a certain minimum or maximum number of characters.

    static

    Parameters

    • min: number

      Minimum length

    • max: number

      Maximum length

    • cfg: default = null

    Returns IValidator

    Configured validation function

  • minMaxNum(min: number, max: number, decimal?: string, cfg?: default): IValidator
  • Check for a numeric input and that it is in between two given values.

    static

    Parameters

    • min: number

      Minimum value

    • max: number

      Maximum value

    • decimal: string = '.'
    • cfg: default = null

    Returns IValidator

    Configured validation function

  • minNum(min: number, decimal?: string, cfg?: default): IValidator
  • Check for a numeric input and that it is greater than a given value.

    static

    Parameters

    • min: number

      Minimum value

    • decimal: string = '.'
    • cfg: default = null

    Returns IValidator

    Configured validation function

  • mjoinMaxCount(size: number, msg: string): IMjoinValidator
  • Require a maximum value of the number of options / values submitted in an array

    static

    Parameters

    • size: number

      Max array size required to be valid

    • msg: string

      Error message

    Returns IMjoinValidator

    Configured validation function

  • mjoinMinCount(size: number, msg: string): IMjoinValidator
  • Require a minimum value of the number of options / values submitted in an array

    static

    Parameters

    • size: number

      Min array size required to be valid

    • msg: string

      Error message

    Returns IMjoinValidator

    Configured validation function

  • noTags(cfg?: default): IValidator
  • Ensure that the submitted string does not contain HTML tags

    static

    Parameters

    • cfg: default = null

    Returns IValidator

    Configured validation function

  • none(cfg?: default): IValidator
  • No validation - all inputs are valid

    static

    Parameters

    • cfg: default = null

    Returns IValidator

    Configured validation function

  • notEmpty(cfg?: default): IValidator
  • Optional field, but if given there must be a non-empty value

    static

    Parameters

    • cfg: default = null

    Returns IValidator

    Configured validation function

  • numeric(decimal?: string, cfg?: default): IValidator
  • Check that any input is numeric.

    static

    Parameters

    • decimal: string = '.'
    • cfg: default = null

    Returns IValidator

    Configured validation function

  • required(cfg?: default): IValidator
  • Required field - there must be a value and it must be a non-empty value

    static

    Parameters

    • cfg: default = null

    Returns IValidator

    Configured validation function

  • url(cfg?: default): IValidator
  • Validate as a URL.

    static

    Parameters

    • cfg: default = null

    Returns IValidator

    Configured validation function

  • values(values: any[], cfg?: default): IValidator
  • Confirm that the value submitted is in a list of allowable values

    static

    Parameters

    • values: any[]

      List of values that are valid

    • cfg: default = null

    Returns IValidator

    Configured validation function

  • xss(cfg?: default): IValidator
  • Check if string could contain an XSS attack string

    static

    Parameters

    • cfg: default = null

    Returns IValidator

    Configured validation function

Generated using TypeDoc