Skip to content
This repository has been archived by the owner on Aug 9, 2023. It is now read-only.

veritem/valdie

Repository files navigation

Valdie

CI npm NPM Downloads

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.

Getting started

npm i valdie

or

yarn add valdie

using deno

import valdie from 'https://cdn.skypack.dev/valdie'

Documentation

  1. isEmail
  2. isInteger
  3. isString
  4. isURL
  5. isDistinct
  6. isIPv4

They are two ways of consuming our api

import { isEmail } from "valdie"

console.log(isEmail("test@test.com")) // true
let { message,success } = isEmail("test@gmail.com")

isInteger

console.log(isInteger(34)) // true

isDistinct

import { isDistinct } from "valdie"

console.log(isDistinct(["true", "false", "yes", "no"]));  // true
let { message,success } = isDistinct([1, 2, 3, 4, 5]);

isIPv4

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")

Maintainers

Licence

The project is under MIT Licence 2021