Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "index"

Index

Type aliases

ExportStructure

ExportStructure<SC>: SC extends StructureChecker<infer T> ? T : never

An helper type which takes a structure-checker type as a parameter and returns structure type of it

Type parameters

  • SC: StructureChecker<any>

    Structure checker type to export structure type from

Nullish

Nullish: null | undefined

Defines the union of 'null' and 'undefined' types

Functions

and

  • Creates an essential structure checker which validates that if input data fits both of the specified structures A and B

    Type parameters

    • A

      First type structure

    • B

      Second type structure

    Parameters

    Returns StructureChecker<A & B>

    Returns a structure checker instance which validates that if input data fits both of the specified structures A and B

array

  • Creates an essential structure checker which validates that if input data is an array of the specified element structure

    Type parameters

    • E

      Type definition of elements in the array

    Parameters

    Returns ArrayStructureChecker<E>

    Returns a structure checker instance which validates that if input data is an array of the specified element structure

boolean

  • Creates an essential structure checker which validates that if type of the input data is 'boolean'

    see

    typename

    Returns StructureChecker<boolean>

    A structure checker instance which validates that if type of the input data is 'boolean'

cast

  • throws

    TypeCastException - Throws TypeCastException if the data doesn't fit into specified type

    Type parameters

    • T

      Specified type of data which is being validated. (Target type)

    • C

      Dummy type parameter which extends T. (Source type)

    Parameters

    • checker: StructureChecker<T>

      Structure checker instance to be used while validation input type

    • data: T extends C ? C : never

      The input data to be checked that if it fits in the structure or not

    Returns T

    Returns input data as T if it fits into T, throws TypeCastException otherwise.

checker

  • Creates a custom structure checker implementation for validations and castings

    Type parameters

    • T

      Specified type of data which is being validated

    Parameters

    • body: StructureCheckerBody<T>

      Validator logic function's body to be used to check that if input data fits in the structure or not while future usages of the checker

    Returns StructureChecker<T>

    StructureChecker instance to be used for validations

constant

  • Creates an essential structure checker which validates that if the input data strictly equals to the specified constant value

    Type parameters

    • V

      Type of specified constant value

    Parameters

    • value: V

      Value to check that if input data strictly equals to

    Returns StructureChecker<V>

    A structure checker instance which validates that if the input data strictly equals to specified constant value

dict

  • Creates an essential structure checker which validates that if input data is and object an its field values fit into the specified one.

    Type parameters

    • V

      Type definition of the desired field value

    • O: {}

      Type definition of the desired structure

    Parameters

    • valueChecker: StructureChecker<V>

      An structure checker which specifies field value type to be used for object validation

    Returns StructureChecker<O>

    Returns a structure checker instance which validates that if input data is and object an its field values fit into the specified one

func

  • Creates an essential structure checker which validates that if type of the input data is 'function'

    see

    typename

    Returns StructureChecker<Function>

    A structure checker instance which validates that if type of the input data is 'function'

instance

  • Creates an essential structure checker which validates that if input data is an instance of the specified constructor or class

    Type parameters

    • T

      Type definition of the specified constructor or class

    Parameters

    • constructor: { constructor: any }

      Specified constructor or class to validate that if input data is an instance of it

      • constructor: function
        • new __type(...args: any[]): T
        • Parameters

          • Rest ...args: any[]

          Returns T

    Returns StructureChecker<T>

    Returns a structure checker instance which validates that if input data is an instance of the specified constructor or class

like

  • Creates an essential structure checker which validates that if the input data weakly equals specified constant value

    Type parameters

    • V

      Type of specified constant value

    Parameters

    • value: V

      Value to check that if input data weakly equals to

    Returns StructureChecker<V>

    A structure checker instance which validates that if the input data weakly equals specified constant value

nul

  • Creates an essential structure checker which validates that if the input data strictly equals to null

    Returns StructureChecker<null>

    A structure checker instance which validates that if the input data strictly equals to null

nullable

  • Creates an essential structure checker which validates that if input data is nullish or fits in the specified structure

    Type parameters

    • T

    Parameters

    • checker: StructureChecker<T>

      Structure checker instance to validate if the input data fits into when the data is not nullish

    Returns StructureChecker<T | Nullish>

    A structure checker instance which validates that if input data is nullish or fits in the specified structure

nullish

  • Creates an essential structure checker which validates that if the input data equals to the null or undefined

    Returns StructureChecker<Nullish>

    A structure checker instance which validates that if the input data equals to the null or undefined

number

  • Creates an essential structure checker which validates that if type of the input data is 'number'

    see

    typename

    Returns StructureChecker<number>

    A structure checker instance which validates that if type of the input data is 'number'

object

  • Creates an essential structure checker which validates that if input data is and object an its field structure fits into the specified one. All properties must be in the object to pass validation even it is nullable. This is the key difference from objectOpt

    Type parameters

    • O: object

      Type definition of the desired structure

    Parameters

    • structure: SpreadObjectDataTypes<O>

      An object which specifies fields and their structures to be used for object validation

    Returns StructureChecker<Required<O>>

    Returns a structure checker instance which validates that if input data is an object and its field structure fits into the specified one

  • Creates an essential structure checker which validates that if input data is an object (or an array). All properties must be in the object to pass validation even it is nullable. This is the key difference from objectOpt

    Returns StructureChecker<{} | []>

    Returns a structure checker instance which validates that if input data is an object (or an array)

objectOpt

  • objectOpt<O>(structure: SpreadObjectDataTypes<O>): StructureChecker<WithOptionals<O>>
  • Works as object, but also converts 'undefined'able fields into optional fields. Nullable properties doesn't have to be in the object to pass validation. This is the key difference from object

    see

    object

    Type parameters

    • O: object

      Type definition of the desired structure

    Parameters

    • structure: SpreadObjectDataTypes<O>

      An object which specifies fields and their structures to be used for object validation

    Returns StructureChecker<WithOptionals<O>>

    Returns a checker instance as how object does, but also converts 'undefined'able fields into optional fields

or

  • Creates an essential structure checker which validates that if input data fits at least one of the specified structures

    Type parameters

    Parameters

    • Rest ...checkers: SCs

      Structures to check that if the input data fits into at least one of them

    Returns StructureChecker<ExtractStructureCheckers<SCs>>

    Returns a structure checker instance which validates that if input data fits at least one of the specified structures

property

  • property<K, V>(key: K, valueCheck: StructureChecker<V>): ObjectStructureChecker<K, V>
  • Creates an essential structure checker which validates that if input data is an object and its specific field's type fits into the specified structure

    Type parameters

    • K: string

      Name definition of the field

    • V

      Type definition of the field value

    Parameters

    • key: K

      Name of the field

    • valueCheck: StructureChecker<V>

      Structure of the field

    Returns ObjectStructureChecker<K, V>

    Returns a structure checker instance which validates that if input data is an object and its specific field's type fits into the specified structure

string

  • Creates an essential structure checker which validates that if type of the input data is 'string'

    see

    typename

    Returns StructureChecker<string>

    A structure checker instance which validates that if type of the input data is 'string'

symbol

  • Creates an essential structure checker which validates that if type of the input data is 'symbol'

    see

    typename

    Returns StructureChecker<symbol>

    A structure checker instance which validates that if type of the input data is 'symbol'

tuple

  • tuple<Es>(...elementCheckers: SpreadArrayDataTypes<Es>): TupleStructureChecker<Es>
  • Creates an essential structure checker which validates that if input data is an array of the specified element structure and its length equals to the length of specified parameters

    Type parameters

    • Es: any[]

      Type definitions tuple of elements in the array

    Parameters

    • Rest ...elementCheckers: SpreadArrayDataTypes<Es>

      Structures of elements in the array

    Returns TupleStructureChecker<Es>

    Returns a structure checker instance which validates that if input data is an array of the specified element structure and its length equals to the length of specified parameters

typename

  • Creates an essential structure checker which validates that if typeof the input data is 'string'

    Parameters

    • name: "string"

      Must be 'string'

    Returns StructureChecker<string>

    A structure checker instance which validates that if typeof the input data is 'string'

  • Creates an essential structure checker which validates that if typeof the input data is 'number'

    Parameters

    • name: "number"

      Must be 'number'

    Returns StructureChecker<number>

    A structure checker instance which validates that if typeof the input data is 'number'

  • Creates an essential structure checker which validates that if typeof the input data is 'boolean'

    Parameters

    • name: "boolean"

      Must be 'boolean'

    Returns StructureChecker<boolean>

    A structure checker instance which validates that if typeof the input data is 'boolean'

  • Creates an essential structure checker which validates that if typeof the input data is 'undefined'

    Parameters

    • name: "undefined"

      Must be 'undefined'

    Returns StructureChecker<undefined>

    A structure checker instance which validates that if typeof the input data is 'undefined'

  • Creates an essential structure checker which validates that if typeof the input data is 'function'

    Parameters

    • name: "function"

      Must be 'function'

    Returns StructureChecker<Function>

    A structure checker instance which validates that if typeof the input data is 'function'

  • Creates an essential structure checker which validates that if typeof the input data is 'object'

    Parameters

    • name: "object"

      Must be 'object'

    Returns StructureChecker<object>

    A structure checker instance which validates that if typeof the input data is 'object'

  • Creates an essential structure checker which validates that if typeof the input data is 'symbol'

    Parameters

    • name: "symbol"

      Must be 'symbol'

    Returns StructureChecker<symbol>

    A structure checker instance which validates that if typeof the input data is 'symbol'

undef

  • Creates an essential structure checker which validates that if the input data strictly equals to undefined

    Returns StructureChecker<undefined>

    A structure checker instance which validates that if the input data strictly equals to undefined

Generated using TypeDoc