Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

joi-verhoeff

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

joi-verhoeff

Verhoeff validation for Joi

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-25%
Maintainers
1
Weekly downloads
 
Created
Source

joi-verhoeff

Provides a Joi rule to validate strings as sequences of numerals with a valid verhoeff checksum digit.

Strings are validated as being entirely composed of digits, and containing a valid checksum using node-verhoeff.

Usage

import BaseJoi from 'joi';
import JoiVerhoeff from 'joi-verhoeff';

const Joi = BaseJoi.extend(JoiVerhoeff);

// Create a joi schema using the Verhoeff validator;
const schema = Joi.string().verhoeff();

Results with valid checksum:

Joi.validate('3789125', Joi.string().verhoeff());
/*
  {
    error: null,
    value: '3789125'
  }
 */

Results with invalid checksum:

Joi.validate('3789122', Joi.string().verhoeff());
/*
{ error: {
    [ValidationError: "value" checksum failure]
    isJoi: true,
    name: 'ValidationError',
    details: [{
      message: '"value" checksum failure',
      path: 'value',
      type: 'string.verhoeff',
      context: { v: '3789122', key: 'value' }
    }],
    ...
  },
  value: '3789122'
}
 */

Keywords

FAQs

Package last updated on 22 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc