Here are some common functions I've used for formatting text in Typescript.
Phone Numbers
Format a string to phone number (ex. 777-787-7979)
Validating a phone number (either formatted or unformatted)
URL
Validate whether a url is valid or not
Validate whether a email address is valid or not
Credit Card
Format a credit card number (ex. 4111 1111 1111 1111)
Deconstruct the formatted credit card (ex. 4111111111111111)
Validate a credit card number (either formatted or unformatted)
Credit Card Expiration Date
Format a credit card expiration (ex. 10/22)
Deconstruct a formatted credit card expiration date (ex. {expMonth: 10, expYear: 22})
Validate a credit card expiration date (either formatted or unformatted)
Comentários