New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

string-mask

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string-mask

A string formatter and validator based on masks

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
22K
increased by6.78%
Maintainers
1
Weekly downloads
 
Created
Source

#string-mask

A string formatter and validator based on Excel like masks.

Installation

With npm

npm install --save string-mask

With bower

bower install --save string-mask

Special mask's characters

CharacterDescription
0Any numbers
9Any numbers (Optional)
#Any numbers (recursive)
AAny aphanumeric character Not implemented yet
aAny aphanumeric character (Optional) Not implemented yet
SAny letter
UAny letter (All lower case character will be mapped to uppercase) Not implemented yet
LAny letter (All upper case character will be mapped to lowercase) Not implemented yet
$Escape character, used to escape any of the special formatting characters.

Usage

Number

	var formatter = new StringMask('#0');
	var result = formatter.apply('123'); // 123

Two Decimal number with thousands separators###

	var formatter = new StringMask('#.##0,00');
	var result = formatter.apply('100123456'); // 1.001.234.56

Phone number

	var formatter = new StringMask('+00 (00) 0000-0000');
	var result = formatter.apply('553122222222'); // +55 (31) 2222-2222

Percentage

	var formatter = new StringMask('#0,00%');
	var result = formatter.apply('001'); // 0,01%

Brazilian CPF number

	var formatter = new StringMask('000.000.000-00');
	var result = formatter.apply('12965815620'); // 129.658.156-20

Date and time

	var formatter = new StringMask('90/90/9900');
	var result = formatter.apply('1187'); // 1/1/87

Keywords

FAQs

Package last updated on 09 Jun 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc