Home Reference Source
import Types from 'bbj-masks/src/Types/Types.js'
public class | source

Types

Types

BBj masks factory

Static Method Summary

Static Public Methods
public static

date(date: String, mask: String, locale: String, timezone: String): String

Mask a date according to bbj masking rules

public static

number(number: Number, mask: String, groupingSeparator: String, decimalSeparator: String, forceTrailingZeros: Boolean, loose: Boolean, ignoreFillChar: Boolean, trimSpaces: Boolean, floatSpecialChars: Boolean): String

Mask the given number with the given mask according to BBj rules

public static

string(str: String, mask: String, loose: Boolean): String

Mask the given string with the given mask according to BBj rules

Static Public Methods

public static date(date: String, mask: String, locale: String, timezone: String): String source

Mask a date according to bbj masking rules

Params:

NameTypeAttributeDescription
date String

date as a string

mask String

mask as a string

locale String
  • optional
  • default: Browser's locale

the language to use ex(en-US). default is to the system language

timezone String
  • optional
  • default: System timezone

the time zone descriptor (e.g. America/Los_Angeles). default to the system timezone

Return:

String

number masked with the given mask

public static number(number: Number, mask: String, groupingSeparator: String, decimalSeparator: String, forceTrailingZeros: Boolean, loose: Boolean, ignoreFillChar: Boolean, trimSpaces: Boolean, floatSpecialChars: Boolean): String source

Mask the given number with the given mask according to BBj rules

Params:

NameTypeAttributeDescription
number Number

the number to format

mask String

the mask to use for formatting

groupingSeparator String
  • optional
  • default: ,

a char which will be used as a grouping separator

decimalSeparator String
  • optional
  • default: .

a char which will be used as a decimal separator

forceTrailingZeros Boolean
  • optional
  • default: false

Affects the output by switching the way a mask with "#" characters in the trailing positions is filled. for example, the function NumberMask.mask(.10:"#.##") returns .10 instead of .1

loose Boolean
  • optional
  • default: true

when true , errors will be ignored and the method will try at apply the mask anyway , otherwise it will stop at first error and throw it.

ignoreFillChar Boolean
  • optional
  • default: false

when true , then the fill char will always be an empty space event if the mask start with a *

trimSpaces Boolean
  • optional
  • default: false

When true , the final masked value will not contain any spaces

floatSpecialChars Boolean
  • optional
  • default: true

When true , then if any of "-", "+", "$", and "(". characters is present in the mask, the first one encountered will be moved to the last position where a "#" or "," was replaced by the fill character. If no such position exists, the float character is left where it

Return:

String

the masked number

Throw:

MaskError

only if loose is disabled

public static string(str: String, mask: String, loose: Boolean): String source

Mask the given string with the given mask according to BBj rules

Params:

NameTypeAttributeDescription
str String

the string to mask

mask String

the mask to use for formatting

loose Boolean
  • optional
  • default: true

when true , errors will be ignored and the method will try at apply the mask anyway , otherwise it will stop at first error and throw it.

Return:

String

the masked string

Throw:

MaskIsTooShortError

StringMaskError

MaskError