npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

verifyr

v1.4.0

Published

Verify node.js data in a easy to use chain syntax, supports arrays, objects and strings

Downloads

24

Readme

Verifyr

Verifyr Website

Verify data in an chain like syntax

const Verify = require("verifyr");

new Verify("verifyr is the best!!!").has("verifyr").isnt("object");

Chaining

Instead of making long if/else statements verifyr allows you to do complex statements with very simple chains Example

var data = new Verify("i dont use chain statements ;(")
console.log(data.has(";(").v() &&
            data.length(5,-1).v() &&
            data.is("string").v())

Can be turned into

var data = new Verify("i use awesome chain statements");
console.log(data.has(":)").length(5,-1).is("string").v());

Valid Types

used with the .is()/.isnt() functions or by getting the property .type

  • bool any boolean (true/false)
  • number any number
  • string any string
  • array any array
  • object any JSON/Pure javascript object

Types only supported using .is()/.isnt()

  • phone a valid phone number format (CANNOT VERIFY NUMBER IS IN USE)
  • email a valid email format (CANNOT VERIFY EMAIL EXISTS)

Methods

Save

takes one optional paramater, if this paramater is true the save will return the .v() response of the save if false/left out the save will return the whole Verify class for that object that you can call more functions on

Example

var save = new Verify().is("string").isnt("number").save();
//can call extra functions on this

console.log(save.test("I am a string").isnt("object").v()); 

//true

var save2 = new Verify().is("string").isnt("number").save(true); 
//cant call extra functions on this

console.log(save.test("I am a string"));
//true

When creating a template for .save() make sure to specify the type if you would like type specific functions like new Verify("object")

V/Valid

call .v() or .valid() on a Verify function to return a boolean that shows if the statement is valid

Length

called on a verifyr object and takes two paramaters min + max length, if either of these varables are -1 it will be infinate in that direction

Example

new Verify("test").length(0,4).v()
// true
new Verify("test").length(2,3).v()
// false

Is

sees if type of object is same as parameter

view valid types here

Example

new Verify("test").is("string").v()
//true

Isnt

sees if type of object is diffrent than parameter

view valid types here

Example

new Verify([a,2]).isnt("string").v()
//true

Has

sees if string/array includes provided parameter

Example

new Verify(Verifyr is amazing).has("verifyr").v()
//true

Equals

returns if data is equal to parameter

Example

new Verify("test").equals("test").v()
//true

Array specific functions

Each

Run a function for each item with the item as paramaters, function must return a bool

Example

new Verify(["1","1"]).each(x => x == "1").v() //makes sure each item is "1"
//true

Object specific functions

Has Child

sees if the object has a child with a specific name

Example

new Verify({x:1,y:2}).hasChild("x").v()
//true

Child

goes to child + sets current data to child

Example

new Verify({x:"string 1",y:"string 2"})
    .child("x")
    .is("string")
    .v()
//true

Parent

goes to parent + sets current data to parent

Example

new Verify({x:"string 1",y:false})
    .child("x")
    .is("string")
    .parent()
    .child("y")
    .is("boolean")
    .v()
//true