JSPM

joi-extension-multihash

2.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q28777F
  • License ISC

Multihash validation with Joi

Package Exports

  • joi-extension-multihash

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (joi-extension-multihash) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

joi-extension-multihash Build Status dependencies Status

Validate a multihash. This is simply a wrapper around the validate method from the multihashes module.

Example

const Joi = require('joi').extend(require('joi-extension-multihash'))
const Assert = require('assert')
let schema, result

// Validate a base 58 encoded multihash string

schema = Joi.multihash().b58()
result = schema.validate('QmWPgGoxjsSazq94f3dvysj17d4pbebqamfMmVXn2DqkG9')
Assert.ifError(result.error)

// Validate a hex encoded multihash string

schema = Joi.multihash().hex()
schema.validate('122077a4018fbde7f967064cd434f6749e80bd37ad3a359c00ab6b94ad98c366da9a')
Assert.ifError(result.error)

// Validate a multihash buffer

schema = Joi.multihash().buffer()
schema.validate(new Buffer())
Assert.ifError(result.error)

js-standard-style