validator字符串验证器
- github: https://github.com/validatorjs/validator.js
- star: 20.2k
- npm Weekly Downloads: 7,464,568
- 使用
npm install validator
import isEmail from 'validator/lib/isEmail';
import isJSON from 'validator/lib/isJSON';
isJSON('{}') // true
- 仅限字符串:如果不知道是否传入的是字符串需要转为字符串;