• Formats a value based on the parameters passed in

    Parameters

    • sqlType: string

      Required - the base type in SQL Server, for example int, nvarchar, etc. For types that have a length like numeric(28,4) or nvarchar(50) do NOT provide the length, just numeric and nvarchar in those examples

    • value: any

      Value to format

    • decimals: number = 2

      Number of decimals to show, defaults to 2

    • currency: string = 'USD'

      Currency to use when formatting, defaults to USD

    • maxLength: number = 0

      Maximum length of the string to return, if the formatted value is longer than this length then the string will be truncated and the trailingChars will be appended to the end of the string

    • trailingChars: string = "..."

      Only used if maxLength is > 0 and the string being formatted is > maxLength, this is the string that will be appended to the end of the string to indicate that it was truncated, defaults to "..."

    Returns string

    either the original string value or a formatted version. If the format cannot be applied an an exception occurs it is captured and the error is put to the log, and the original value is returned