Skip to content

Latest commit

 

History

History
38 lines (26 loc) · 559 Bytes

README.md

File metadata and controls

38 lines (26 loc) · 559 Bytes

Mask

Simple input and string masking library.

Example

type Msg
    = PhoneUpdated String


type alias Phone =
    { number : String

    -- ...
    }


update : Msg -> Phone -> Phone
update msg phone =
    case msg of
        PhoneUpdated number ->
            { phone | number = number }


phonePattern : Pattern
phonePattern =
    Mask.fromString "(###)###-####"


view : Phone -> Html msg
view { number } =
    input
        [ maskedValue phonePattern number
        , onMaskedInput phonePattern number PhoneUpdated
        ]
        []