datatables.net-editor-server
    Preparing search index...

    Class Validate

    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.

    Validator

    Index

    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.

      Parameters

      • Optionalcfg: default | null = null

        Validation options

      Returns IValidator

      Configured validation function

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

      Parameters

      • format: string

        MomentJS date format

      • Optionallocale: string | null = null

        MomentJS locale

      • Optionalcfg: default | null = null

        Validation options

      Returns IValidator

      Configured validation function

    • Check that the given value is unique in the database

      Parameters

      • Optionalcfg: default | null = null

        Validation options

      • Optionalcolumn: string | null = null

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

      • Optionaltable: string | null = null

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

      • Optionaldb: Knex<any, any[]> | null = null

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

      Returns IValidator

      Configured validation function

    • 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.

      Parameters

      • Optionalcfg: default | null = null

        Validation options

      • Optionalcolumn: string | null = null

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

      • Optionaltable: string | null = null

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

      • Optionaldb: Knex<any, any[]> | null = null

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

      • values: any[] = []

      Returns IValidator

      Configured validation function

    • Check that the uploaded file has a given extension

      Parameters

      • extns: string[]

        Allowed extensions

      • msg: string

        Error message to return if not valid

      Returns IFileValidator

      Configured validation function

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

      Parameters

      • size: number

        Max file size in bytes

      • msg: string

      Returns IFileValidator

      Configured validation function

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

      Parameters

      • max: number

        Maximum length

      • Optionalcfg: default | null = null

        Validation options

      Returns IValidator

      Configured validation function

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

      Parameters

      • max: number

        Maximum value

      • Optionaldecimal: string = '.'

        Character to use as the decimal place

      • Optionalcfg: default | null = null

        Validation options

      Returns IValidator

      Configured validation function

    • Validate a string has a minimum length.

      Parameters

      • min: number

        Minimum length

      • Optionalcfg: default | null = null

        Validation options

      Returns IValidator

      Configured validation function

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

      Parameters

      • min: number

        Minimum length

      • max: number

        Maximum length

      • Optionalcfg: default | null = null

        Validation options

      Returns IValidator

      Configured validation function

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

      Parameters

      • min: number

        Minimum value

      • max: number

        Maximum value

      • Optionaldecimal: string = '.'

        Character to use as the decimal place

      • Optionalcfg: default | null = null

        Validation options

      Returns IValidator

      Configured validation function

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

      Parameters

      • min: number

        Minimum value

      • Optionaldecimal: string = '.'

        Character to use as the decimal place

      • Optionalcfg: default | null = null

        Validation options

      Returns IValidator

      Configured validation function

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

      Parameters

      • size: number

        Max array size required to be valid

      • msg: string

        Error message

      Returns IMjoinValidator

      Configured validation function

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

      Parameters

      • size: number

        Min array size required to be valid

      • msg: string

        Error message

      Returns IMjoinValidator

      Configured validation function

    • Check that any input is numeric.

      Parameters

      • Optionaldecimal: string = '.'

        Character to use as the decimal place

      • Optionalcfg: default | null = null

        Validation options

      Returns IValidator

      Configured validation function

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

      Parameters

      • Optionalcfg: default | null = null

        Validation options

      Returns IValidator

      Configured validation function

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

      Parameters

      • values: any[]

        List of values that are valid

      • Optionalcfg: default | null = null

        Validation options

      Returns IValidator

      Configured validation function