Simple libreary to mask strings and inputs.
Creates a pattern from a String, using
phonePattern : Pattern
phonePatter =
Mask.fromString "(###)###-####"Masks a string, useful for displaying formatted data.
maskPhone : String -> String
maskPhone phoneNumber =
Mask.mask phonePattern phoneNumber
maskPhone "1231231234" == "(123)123-1234"Unmasks a string.
unmaskPhone : String -> String
unmaskPhone phoneNumber =
Mask.unMask phonePattern phoneNumber
maskPhone "(123)123-1234" == "1231231234"Similar to Html.Attributes.value, but applying the provided pattern
input [ maskedValue phonePattern model.phoneNumber ] []Similar to Html.Events.onInput, but unmasking a masked value. It requires the previous value as the second argument
type Msg = SetPhone String
input
[ maskedValue phonePattern model.phoneNumber
, onMaskedValue phonePattern model.phoneNumber SetPhoneNumber
]
[]
Represent the pattern that will be applied to the string to mask