Massolari/elm-mask/1.0.0

NOTE: the latest version is 1.1.1

Mask

A mask is a formatting pattern that you can apply to a value. This module has some functions to help you create and apply masks.

Common Helpers

string : String -> String -> String

Formats a string using a pattern. A pattern is a string where the # is going to be replaced by a character of the input

string "#-##-#" "1b0a" == "1-b0-a"


string "FOO##.###.##BAR" "EXAMPLE" == "FOEX.AMP.LEBAR"
number : String -> String -> String

Formats a string filtering only the numbers of it

number "(##) ####-####" "1234567890" == "(12) 3456-7890"


number "#-##-#" "1b0a" == "1-0"

Formating numbers

floatDecimal : DecimalOptions -> Float -> String

Formats a Float number according to the specified options

floatDecimal defaultDecimalOptions 10500.5 == "10.500.50"


floatDecimal { defaultDecimalOptions | precision = 3, decimal = ",", thousand = "." } 10500.5 == "1.050,050"
intDecimal : DecimalOptions -> Int -> String

Formats a Int number according to the specified options

intDecimal defaultDecimalOptions 105005 == "1,050.05"


intDecimal { defaultDecimalOptions | precision = 3, decimal = "," } 105005 == "105,005"
defaultDecimalOptions : DecimalOptions

Default options to format numbers