Parser for LookupKey.Number. It supports decimal and integer values, both positive and negative. Use validators to detect invalid numbers like having a negative or decimal when not desired.

Hierarchy (view full)

Constructors

Properties

badNumberMessage: "Expecting a number" = 'Expecting a number'

Accessors

  • get supportedCultures(): string[]
  • All cultureIds that support the order and separator. Note that if there is language-specific culture and one that is not language specific but has the same local, you can define just the one for the local because the DataTypeParser service will search both language specific and language agnostic when the CultureService is setup with fallbacks.

    Returns string[]

  • get stripTheseStrings(): string | string[]
  • Any special formatting strings that are meaningful to the user but can be discarded during parsing. Consider the currency symbol and percent symbol. Don't use this for negative character as once identified as negative, the all negative symbols are stripped prior to parsing and the resolved number is still negated.

    Returns string | string[]

  • set stripTheseStrings(value): void
  • Parameters

    • value: string | string[]

    Returns void

Methods

  • If the user needs to abandon this instance, they should use this to clean up active resources (like timers) and to release memory that would stall the garbage collector from disposing this object. It should assign any object reference to undefined as a strong indicator that the object has been disposed.

    Returns void

  • In addition to matching by dataTypeLookupKey, it also requires the text to match a regular expression. The expression reflects the one or very few patterns that parse() expects to work with. By the time parse() is called, it knows the expression has the pattern and can simply work within the regexp results.

    Parameters

    • dataTypeLookupKey: string
    • cultureId: string
    • text: string

    Returns boolean

  • Since there can be several parsers for a single lookupKey and cultureID that are selected based on the text, this function is used when you want all possible candidates. It is effectively supports() without the text.

    Parameters

    • dataTypeLookupKey: string
    • cultureId: string

    Returns boolean

  • Expect the output to be setup for a regular expression that looks for either: digits + period + digits minus + digits + period + digits digits minus + digits Anything else will be rejected by the regular expression as invalid.

    Parameters

    • text: string
    • dataTypeLookupKey: string
    • cultureId: string

    Returns string

  • Responsible for anything that cannot be a number and number patterns that conform to the current options, like have a currencysymbol only when its setup. When its a number that cannot work with the options, reject it so another registered number parser can deal with it. That way, the NumberParser doesn't try to handle what was intended for CurrencyParser or PercentageParser.

    Parameters

    • dataTypeLookupKey: string
    • cultureId: string
    • text: string

    Returns boolean

  • Expects the string to be: optional minus (in group named "neg") 1 or more digits, allowing for lead zeros (in group named "whole") optional period if period, optional 1 or more digits allowing for trailing zeros (in group named "decimal"). This resulting pattern should completely cover the text except for lead and trailing whitespace. After whitespace trimming, we should be able to use parseFloat or parseInt on the text.

    Parameters

    • dataTypeLookupKey: string
    • cultureId: string

    Returns RegExp

Generated using TypeDoc v0.25.12