Options
All
  • Public
  • Public/Protected
  • All
Menu

DataType - converter for values in URL.

Converts string value from url into javascript representation (for example, a number) and vice versa

Type parameters

  • T

    a typescript type to which the url parameter is converted to

Hierarchy

  • DataType

Index

Properties

Methods

Properties

name

name: string

data type's name, for example int. This is the key that is present in route's meta before ':'

Methods

parse

  • parse(value: null | string | LocationQueryValue[], defaultValue: T): T
  • Parses value from the url

    Parameters

    • value: null | string | LocationQueryValue[]

      value as found in the url. Might be a single string (if the parameter is present once) or an array of strings (if the argument is present multiple times) It might be also null (or string of nulls), if the argument does not have a value (...?strict&strict&strict)

    • defaultValue: T

      the default value previously parsed via parseDefault

    Returns T

parseDefault

  • parseDefault(value: string): T | (() => T)
  • Parse default value from the configuration. For example, if the configuration is int:1, the datatype is int and the default value 1. This function takes the default value and returns the javascript value (of type T)

    Parameters

    • value: string

      the default value to be parsed

    Returns T | (() => T)

    Either the default value or a function producing the default value (for modifiable types, such as empty array - so that it stays empty whenever default value is passed)

serialize

  • serialize(value: T, defaultValue: T): undefined | null | string | string[]
  • Serializes the value to string, array of string, null or undefined.

    Parameters

    • value: T

      javascript value

    • defaultValue: T

      value that will be put to url

    Returns undefined | null | string | string[]

    • undefined if the parameter should be removed from url (for example, is equal to the default value)
    • null if the parameter should be put to url without a value (for example ?strict)
    • string param=string will be put to url query
    • string[] param=string[0]&param=string[1]... will be put to url query

Legend

  • Property
  • Method

Generated using TypeDoc