{"id":48230,"library":"joi-browser","title":"joi-browser","description":"joi-browser is a browser-ready bundle of the Joi object schema validation library (version 13.4.0, latest stable). It is pre-babelified and bundled for use in browsers with tools like Webpack or Browserify, avoiding the difficulties of bundling Joi natively. The package provides an ES5-compatible bundle and supports isomorphic/universal JavaScript by aliasing Joi in module bundlers. It requires polyfills for Promise and Map in older browsers and has an alternate 'joi-full' variant that includes date extensions. Community-driven alternative to native Joi, last updated in 2019.","status":"maintenance","version":"13.4.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/jeffbski/joi-browser","tags":["javascript"],"install":[{"cmd":"npm install joi-browser","lang":"bash","label":"npm"},{"cmd":"yarn add joi-browser","lang":"bash","label":"yarn"},{"cmd":"pnpm add joi-browser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Use joi-browser import in browser; on server, require 'joi' directly. For isomorphic setups, alias 'joi' to 'joi-browser' in bundler config.","wrong":"const Joi = require('joi')","symbol":"default (Joi)","correct":"import Joi from 'joi-browser'"},{"note":"CommonJS require returns the default export directly, so no .default needed.","wrong":"const joi = require('joi-browser').default","symbol":"Joi (CommonJS)","correct":"const Joi = require('joi-browser')"},{"note":"In Joi v13, .validate() is a static method on Joi, not on schema objects (changed from earlier versions).","wrong":"schema.validate(value)","symbol":"validate method","correct":"Joi.validate(value, schema, options)"}],"quickstart":{"code":"// Install: npm install joi-browser\n// Polyfills for older browsers: npm install es6-promise es6-map\nrequire('es6-promise').polyfill();\nrequire('es6-map/implement');\n\nconst Joi = require('joi-browser');\n\nconst schema = Joi.object().keys({\n  username: Joi.string().alphanum().min(3).max(30).required(),\n  password: Joi.string().regex(/^[a-zA-Z0-9]{3,30}$/),\n  birthyear: Joi.number().integer().min(1900).max(2013),\n  email: Joi.string().email({ minDomainSegments: 2 })\n}).with('username', 'birthyear').without('password', 'access_token');\n\nconst data = { username: 'abc', birthyear: 1994 };\nconst result = Joi.validate(data, schema);\n// result.error === null, result.value === { username: 'abc', birthyear: 1994 }","lang":"javascript","description":"Demonstrates basic schema validation using Joi's object schema, including .keys(), .string(), .number(), and validation with error checking."},"warnings":[{"fix":"For latest Joi features, consider using the official 'joi' package with a polyfill or browser build.","message":"joi-browser is not an official Hapi.js package; it is a community fork. It may lag behind official Joi releases and may have different behavior.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Replace schema.validate(value) with Joi.validate(value, schema) or schema.validateAsync(value).","message":"The .validate() method on schema objects is deprecated in Joi v13; use Joi.validate() or the .validateAsync() method.","severity":"gotcha","affected_versions":">=13.0.0"},{"fix":"Include polyfills such as 'es6-promise' and 'es6-map' before loading joi-browser.","message":"Requires polyfills for Promise and Map in browsers that do not support ES6 (e.g., IE11). Without polyfills, errors like 'Promise is not defined' may occur.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"In webpack config, add exclude: /joi-browser/ to the Babel loader rule.","message":"When using Webpack with a Babel loader, joi-browser must be excluded from Babel transformation to avoid double-transpilation issues.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use the default bundle for bundling; consider building your own minified version with your toolchain.","message":"The default bundle is unminified; minified version is available as dist/bundle.min.js but may not be up to date.","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'13.4.0':21 '2019':98 'alias':61 'altern':79,91 'avoid':41 'babelifi':28 'browser':3,6,10,34,75 'browser-readi':9 'browserifi':40 'bundl':12,30,45,55 'bundler':65 'communiti':89 'community-driven':88 'compat':54 'date':86 'difficulti':43 'driven':90 'es5':53 'es5-compatible':52 'extens':87 'full':82 'includ':85 'isomorphic/universal':58 'javascript':59,99 'joi':2,5,15,46,62,81,94 'joi-brows':1,4 'joi-ful':80 'last':95 'latest':22 'librari':19 'like':37 'map':72 'modul':64 'nativ':47,93 'object':16 'older':74 'packag':49 'polyfil':68 'pre':27 'pre-babelifi':26 'promis':70 'provid':50 'readi':11 'requir':67 'schema':17 'stabl':23 'support':57 'tool':36 'updat':96 'use':32 'valid':18 'variant':83 'version':20 'webpack':38","created_at":"2026-06-07T16:55:33.753031+00:00","updated_at":"2026-06-07T16:55:33.753031+00:00","problems":[{"fix":"Run 'npm install joi-browser' and ensure import statement uses 'joi-browser', not 'joi'.","cause":"The module is not installed or the import path is incorrect; possibly using 'joi' instead of 'joi-browser' in browser code.","error":"Error: Cannot find module 'joi-browser'"},{"fix":"Use Joi.validate() correctly: Joi.validate(value, schema). For Joi v16+, use schema.validateAsync(value).","cause":"The version of Joi used may be >13 where .validate() is no longer a static method; or the import is wrong (default vs named).","error":"TypeError: Joi.validate is not a function"},{"fix":"Add a Promise polyfill (e.g., 'es6-promise') before loading joi-browser.","cause":"The browser environment lacks ES6 Promise support. joi-browser uses Promises internally.","error":"ReferenceError: Promise is not defined"},{"fix":"Configure alias in webpack (resolve.alias) or browserify (package.json browser field) as documented.","cause":"Webpack/Browserify alias not configured; when using require('joi'), the bundler tries to resolve the original joi package.","error":"Module build failed: Error: Cannot find module 'joi' (while using joi-browser)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/jeffbski/joi-browser#readme","github":"ssh://git@github.com/jeffbski/joi-browser","docs":null,"changelog":null,"pypi":null,"npm":"joi-browser","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}