tableflip/joi-multiaddr

Name: joi-multiaddr

Owner: TABLEFLIP

Description: Multiaddr validation with Joi

Created: 2018-02-28 09:43:25.0

Updated: 2018-04-06 16:25:35.0

Pushed: 2018-04-06 16:25:34.0

Homepage: null

Size: 162

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

joi-multiaddr

Build Status dependencies Status JavaScript Style Guide

Validate a multiaddr and common formats.

Install
install joi-multiaddr
Usage
t Joi = require('joi').extend(require('joi-multiaddr'))


alidate a String or Buffer is in multiaddr format:


t schema = Joi.multiaddr()
t result = schema.validate('/ip4/0.0.7.6/tcp/1234')

ole.log(result.error) // null
ote, successful validation converts to a Multiaddr instance:
ole.log(result.value) // <Multiaddr 04000007060604d2 - /ip4/0.0.7.6/tcp/1234>


alidate formats using mafmt (https://github.com/multiformats/js-mafmt):


t dnsSchema = Joi.multiaddr().DNS()
t tcpSchema = Joi.multiaddr().TCP()
t ipfsSchema = Joi.multiaddr().IPFS()
tc. */

Schema.validate('/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4') // Success!
Schema.validate('/ip4/0.0.7.6/tcp/1234') // Failure :(
Contribute

Feel free to dive in! Open an issue or submit PRs.

License

MIT © Alan Shaw


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.