Joi validators for IPFS.
Example
const Joi = const Assert = const schema = Joi let result = schemaAssertconsole // /ipfs/QmWPgGoxjsSazq94f3dvysj17d4pbebqamfMmVXn2DqkG9
Strict mode
By default, joi-extension-ipfs
will validate an IPFS path if it looks like it might be one. Pass strict: true
to enable strict path validation.
const Joi = const Assert = const strictSchema = Joiconst schema = Joi // Multihash only let result = strictSchemaAssert // throws result = schemaconsole // /ipfs/QmWPgGoxjsSazq94f3dvysj17d4pbebqamfMmVXn2DqkG9 // Missing leading forward slash result = strictSchemaAssert // throws result = schemaconsole // /ipfs/QmWPgGoxjsSazq94f3dvysj17d4pbebqamfMmVXn2DqkG9 // Missing protocol result = strictSchemaAssert // throws result = schemaconsole // /ipfs/QmWPgGoxjsSazq94f3dvysj17d4pbebqamfMmVXn2DqkG9/foo.jpg
Validate ONLY a multihash?
Take a look at joi-extension-multihash
.