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

@nialloc9/vcheck

v1.0.15

Published

A validator library for common use cases.

Downloads

30

Readme

vcheck

A validator library for common use cases.

Latest stable release

  • 1.0.9

Usage

  • install package

      $ npm i --save @nialloc9/vcheck
  • use on it's own and call function

      import { validateRequired } from 'nialloc9@vcheck';
    
      const error = validateRequired(myValue);
    
      if(error) throw new Error(error);
  • use multiple validators in a pipeline

      import { validateRequired, validateTelephoneNumber, pipeline } from 'nialloc9@vcheck';
    
      const error = pipeline([validateRequired, validateTelephoneNumber], myValue); -> order matters as validateRequired will be first rule tested
    
      if(error) throw new Error(error);
  • or easily integrate with redux-form package

      import { validateRequired } from 'nialloc9/vcheck';
      import { Field } from 'redux-form';
    
      <Field
      name="name"
      size="small"
      type="text"
      component="input"
      validate={validateRequired}

    />

Methods

  • All methods return an error message if value is not correct. Or undefined if valid value passed.
  • @description validates whether a password confirmation has been entered

  • @param {{string}} value - value

  • @returns {string | undefined}

      validateRequired(myValue)
  • @description validates a phone number is 11 digits

  • @param {{string}} value - value

  • @returns {string | undefined}

      validatePhoneNumber(myValue)
  • @description public validates whether a value less than a max number

  • @param {{number}} max - value

  • @returns {string | undefined}

      const maxLength8 = validateMaxLength(8)
    
      maxLength8(myValue);
  • @description public validates whether a value more than a min length

  • @param {{number}} min - value

  • @returns {string | undefined}

      const minLength3 = validateMinLength(3);
    
      minLength3(myValue);
  • @description validates if a value is a number

  • @param {{string}} value - value

  • @returns {string | undefined}

      validateNumber(myValue);
  • @description validates whether an number is greater than min

  • @param {{number}} min - value

  • @returns {string | undefined}

      const minValue3 = validateMinValue(3);
    
      minValue3(myValue);
  • @description validates whether an email has been entered

  • @param {{number}} max - value

  • @returns {string | undefined}

      const maxValue10 = validateMaxValue(10);
    
      maxValue10(myValue);
  • @description validates whether a valid email has been entered

  • @param {{string}} value - value

  • @returns {string | undefined}

      validateEmail(myValue)
  • @description validates whether a country has been entered

  • @param {{string}} value - value

  • @returns {string | undefined}

      validateRequiredCountry(myValue);
  • @description validates whether a number has been entered

  • @param {{string}} value - value

  • @returns {string | undefined}

      validateRequiredNumber(myValue);
  • @description validates whether a name has been entered

  • @param {{string}} value - value

  • @returns {string | undefined}

      validateRequiredName(myValue);
  • @description validates whether a last name has been entered

  • @param {{string}} value - value

  • @returns {string | undefined}

      validateRequiredLastName(myValue);
  • @description validates whether an address has been entered

  • @param {{string}} value - value

  • @returns {string | undefined}

      validateRequiredAddress(myValue);
  • @description validates whether an pst code has been entered

  • @param {{string}} value - value

  • @returns {string | undefined}

       validateRequiredPostCode(myValue);
  • @description validates whether terms have been accepted

  • @param {{string}} value - value

  • @returns {string | undefined}

      validateAcceptedTerms(myValue);
  • @description validates if email is present

  • @param {string} value

  • @returns {string | undefined}

       validateRequiredEmail(myValue);
  • @description validates whether a password has been entered

  • @param {{string}} value - value

  • @returns {string | undefined}

      validateRequiredPassword(myValue);
  • @description validates whether a password confirmation has been entered

  • @param {{string}} value - value

  • @returns {string | undefined}

      validateRequiredPasswordConfirmation(myValue);
  • @description validates whether a day has been entered

  • @param {{string}} value - value

  • @returns {string | undefined}

       validateRequiredDay(myValue);
  • @description validates whether a time has been entered

  • @param {{string}} value - value

  • @returns {string | undefined}

       validateRequiredTime(myValue);
  • @description validates whether a correct telephone number has been entered

  • @param {{string}} value - value

  • @returns {string | undefined}

       validateTelephoneNumber(myValue);
  • @description validates whether a valid message is entered

  • @param {{string}} value - value

  • @returns {string | undefined}

       validateRequiredMessage(myValue);
  • @description validates whether a correct domain has been entered

  • @param {{string}} value - value

  • @returns {string | undefined}

       validateDomain(myValue);
  • @description validates whether a string with special chars has been entered

  • @param {{string}} value - value

  • @returns {string | undefined}

       validateSpecialChars(myValue);
  • @description runs validators on value from left to right

  • @param {{func}} validators

  • @param {{string}} value

  • @returns {string | undefined}

       pipeline([validateRequiredMessage, validateDomain], myValue);
  • @description runs validators on value from left to right as a hof

  • @param {{func}} validators

  • @param {{string}} value

  • @returns {string | undefined}

       pipelineHof([validateRequiredMessage, validateDomain])(myValue);
         

Testing

  • Run the tests $ npm run test

Contributing

Contributions are always welcome. Just open a PR.

Notes

Sample logo in assets created using: https://logomakr.com/