2
0
mirror of https://github.com/tenrok/maska.git synced 2026-06-17 19:21:21 +03:00

Updated docs about token transform functions

This commit is contained in:
Alexander Shabunevich
2020-10-10 21:45:58 +03:00
parent 2237462972
commit 7cc8274b85
9 changed files with 72 additions and 15 deletions
+10
View File
@@ -117,6 +117,16 @@ Default tokens:
You can add your own tokens by passing them in `maska` directive or `create` method at initialization (see above). **Important**: `pattern` field should be JS *regular expression* (`/[0-9]/`) or *string without delimiters* (`"[0-9]"`).
### Transform function for tokens
While specifying custom tokens you can also add a symbol-transformation behavior such as uppercase, lowercase, or even define a transform function:
``` javascript
{
'T': { pattern: /[0-9]/, transform: (char) => String(Number(char) % 2) } // '1234567890' -> '1010101010'
}
```
## Dynamic masks
To use several masks on single input, pass array instead of string as mask value.