CI / CD | Status |
---|---|
NPM | |
Semaphore CI | |
Circle CI | |
Coverall | |
SonarCloud |
validate
validates a string. If string is valid, return true.
Useful in forms.
It validates an email or against an external regular expression.
You can pass a second parameter as true to use a third parameter as regular expression.
Installation
npm install @sineverba/validate
Usage
import { validate } from "@sineverba/validate";
console.log(validate("info@example.com")); // It prints true
console.log(validate("infoexample.com")); // It prints false
console.log(validate("qwerty1234_", true, /^[a-zA-Z0-9_]+$/)); // It prints true, accept only alfphanumeric and underscore
Tests
npm run test
for simple test
npm run coverage
for coverage