-
Notifications
You must be signed in to change notification settings - Fork 93
Home
Egor Taflanidi edited this page Feb 4, 2019
·
14 revisions
Input Mask
is an Android & iOS native library allowing to format user input on the fly.
The library provides you with a text field listener; when attached, it puts separators into the text while user types it in, and gets rid of unwanted symbols, all according to custom predefined pattern.
This allows to reformat whole strings pasted from the clipboard, e.g. turning pasted 8 800 123-45-67
into 8 (800) 123 45 67
.
Each pattern allows to extract valuable symbols from the entered text, returning you the immediate result with the text field listener's callback when the text changes.
Mask examples:
- International phone numbers:
+1 ([000]) [000] [00] [00]
- Local phone numbers:
([000]) [000]-[00]-[00]
- Names:
[A][-----------------------------------------------------]
- Text:
[A…]
- Dates:
[00]{.}[00]{.}[9900]
- Serial numbers:
[AA]-[00000099]
- IPv4:
[099]{.}[099]{.}[099]{.}[099]
- Visa card numbers:
[0000] [0000] [0000] [0000]
- MM/YY:
[00]{/}[00]
Refer to the Mask syntax chapter for the formatting rules.
Throughout this Uncyclo we use a custom set of terms:
- text field — a field with our library's text field listener attached;
- input — everything user writes or pastes into the text field;
- mask — a pattern, which defines how to format the input;
- output — everything user actually sees inside the text field;
- extracted value — a string of valuable characters distilled from the input;
- complete or value completeness — a boolean flag indicating that the extracted value is complete;
- compiler — an internal entity, which translates masks into the state machine graphs.