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 🙏

© 2026 – Pkg Stats / Ryan Hefner

form-validation-thieny

v2.0.0

Published

Validate input data

Readme

Build Status

Introduction

This lib use for validate javascript form data object send to API before we using this data. Reuse any type of data we defined.

Example

var thieny = require('form-validation-thieny');

let data = {
  email: '[email protected]',
  new_email: '[email protected]'
};

let result = thieny.required('email') // could be array ['email']
                    .optional('new_email', 'old_email') // could be array ['new_email', 'old_email']
                    .validate(data);

console.log(result);
// success
// {
//   error: null,
//   value: {
//     email: '[email protected]',
//     new_email: '[email protected]'
//   }
// }

// any error
// {
//   error: {
//     code: 1,
//     msg: 'Invalid email'
//   },
//   value: {}
// }

Try Online Demo

Before do validate, just defined object type and put them when your app start (run first)

// add new type defined email type and error that you want to response
thieny.add_type({
  type_name: 'email',
  error_data: {
    code: 1,
    msg: 'Invalid email'
  },
  validate: str => {
    if (str) {
      return {
        value: str
      };
    } else {
      return {
        error: true
      }
    }
  },
  field_names: [{
    name: 'new_email'
  }, {
    name: 'old_email',
    error_data: {
      code: 4,
      msg: 'Invalid old email'
    }
  }]
});

Usage

add_type

Add new type

  • type_name String name of type
  • error_data Any error object return when invalid data.
  • validate Function function validate data: Can be yourself function or using @hapi/joi module

Your function

validate: str => {
  // your validate function here
  if (str) {
    return {
      value: str
    };
  } else {
    return {
      error: true
    }
  }
}

Using @hapi/joi Reference API Reference.

validate: str => {
  // using @hapi/joi
  return thieny.joi.string().trim().replace(/[^0-9]/g, '').length(10).validate(str);
}

Return an object

  • error Boolean optional true/false
  • value Any value of input after validate
  • field_names Array optional list of fields had the same type
    • name
    • error_data optional error object return when invalid data

required

List of field (arg or array) are required in input data

optional

List of field (arg or array) are optional in input data

validate

Validate an object data Return an object

  • error Any error_data which you defined before in add_type
  • value Object An object was return if no error after validate.