String validators and sanitizers for JavaScript
open sourceMITfree
validator.js is a JavaScript library of string validators and sanitizers for Node.js and the browser. It checks whether a string is an email address, URL, IP address, UUID, credit card number, IBAN, ISBN, JWT, date, mobile phone number, postal code, strong password and many other formats, and sanitizes strings by trimming, escaping and normalizing them. It works on strings only, and each validator can be imported on its own or as tree-shakeable ES modules.
Problems it solves
- check whether a string is a valid email address in JavaScript
- validate a phone number or postal code for a given country in Node.js
- sanitize and normalize user input strings in a web form
Features
- validators for email, URL, IP, UUID, IBAN, ISBN, credit card and many other formats
- locale-aware checks for mobile phone numbers, postal codes and identity cards
- sanitizers such as trim, escape, normalizeEmail and whitelist
- import single validators or tree-shakeable ES modules
- runs in Node.js and in the browser
Limitations
Alternatives
The same job
These do what validator.js does.
- express-validator Express middleware that validates and sanitizes requests with validator.js
