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

joi-full

v10.0.6-rel3

Published

joi object schema validation with extensions - universal/isomorphic works with Node.js and is bundled for the browser

Downloads

1,361

Readme

joi-full

joi object schema validation with extensions as universal/isomorphic libarary for Node.js and bundled for the browser (babelified and bundled). Includes joi-date-extensions.

Build Status NPM Version Badge

Why?

There has been some difficulty in getting a reasonable version of Joi packaged for the browser both due to the size of bundling and with Joi 7.x.x switching to ES6 modules has added additional challenges.

I made a browser build of joi available at joi-browser, but Joi@10 split date functionality into its own package joi-date-extensions, so I also created joi-date-extensions-browser but currently are having trouble when combining joi-browser and joi-date-extensions together.

In the meantime, this build was created which includes joi and joi-date-extensions and works on Node.js and provides a bundle for brower builds.

Usage

Moment is a peer dependency so it needs to be installed as well.

npm install joi-full moment
var Joi = require('joi-full'); // includes joi-date-extensions

Note: if you are using webpack with a babel loader you may need to exclude joi-full from being run through babel again.

In your webpack.config.js loaders, add an exclude: [ /joi-full/ ]

Isomorphic / Universal JS - using in browser and on server (Node.js)

The joi-full package.json includes the browser field which directs browser builds to use to the prebuilt dist/joi-full.js

Webpack

An example of using joi-full with webpack is in examples/webpack-basic

npm install joi-full moment

You might need to add the following to your app's webpack.config.js to enable the package aliasing we configured in package.json

  resolve: {
    packageAlias: 'browser'
  }

Note: if you are using webpack with a babel loader you may need to exclude joi-full from being run through babel again.

In your webpack.config.js loaders, add an exclude: [ /joi-full/ ].

So in your code, you just require joi-full

var Joi = require('joi-full'); // includes joi-date-extensions

Browserify

You can also use browserify to use joi-full. It should pick up the proper bundled file when it reads joi-full/package.json browser field.

npm install joi-full moment

So in your code, you just require joi-full

var Joi = require('joi-full'); // includes joi-date-extensions

There is an example in examples/browserify-basic.

Examples

There are three examples:

  • examples/browserify-basic - uses browserify to bundle joi-full with our src for browser
  • examples/node-basic - use joi-full with node.js
  • examples/webpack-basic - use webpack to bundle joi-full with our src for the browser

To use any of them:

cd examples/___
npm install
npm start

Development

# builds dist/joi-full.js and dist/joi-full.min.js
npm install
npm run prepublish # when you want to rebuild

Discussion

The main discussion about these difficulties has been in this github issue.

https://github.com/hapijs/joi/issues/528#issuecomment-128532221

See joi-browser for more details on the bundling issues.

Since this package is simply a bundling of the original joi and joi-date-extensions, please discuss defects or suggestions for those packages at: