A TypeScript and JavaScript Validation Library that works
- 🎉 It doesn't have any dependancy
- 💪 Simple api
- 📦 It works with TypeScript
You probably never knew you needed it but here you go.
npm i valdie
or
yarn add valdie
using deno
import valdie from 'https://cdn.skypack.dev/valdie'
import { isEmail } from "valdie"
console.log(isEmail("test@test.com")) // true
let { message,success } = isEmail("test@gmail.com")
console.log(isInteger(34)) // true
import { isDistinct } from "valdie"
console.log(isDistinct(["true", "false", "yes", "no"])); // true
let { message,success } = isDistinct([1, 2, 3, 4, 5]);
Version 4 IP addresses (IPv4) validator
import { isIPv4 } from "valdie"
// sample
console.log( isIPv4('192.168.0.3') ) // { success : true }
console.log( isIPv4('rrtr3345') ) // { message : "rrtr3345 is not a valid IPv4" , success : false }
// usage
const myIp : string = "192.168.1.1"
const { message , success } = isIPv4(myIp)
if(success)
console.log("myIp is an IPv4 address")
else
console.log("It's not an IPv4 address")
The project is under MIT Licence 2021