Socket
Socket
Sign inDemoInstall

joi

Package Overview
Dependencies
Maintainers
6
Versions
238
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

joi - npm Package Compare versions

Comparing version 12.0.0 to 12.1.1

LICENSE.md

6

lib/cast.js
'use strict';
// Load modules
const Hoek = require('hoek');
const Hoek = require('hoek');
const Ref = require('./ref');
// Type modules are delay-loaded to prevent circular dependencies
// Declare internals
const internals = {};

@@ -14,0 +10,0 @@

'use strict';
// Load modules
const Hoek = require('hoek');
const Hoek = require('hoek');
const Language = require('./language');
// Declare internals
const internals = {

@@ -15,2 +12,3 @@ annotations: Symbol('joi-annotations')

internals.stringify = function (value, wrapArrays) {

@@ -49,2 +47,3 @@

exports.Err = class {

@@ -203,2 +202,3 @@

// Inspired by json-stringify-safe
internals.safeStringify = function (obj, spaces) {

@@ -209,2 +209,3 @@

internals.serializer = function () {

@@ -211,0 +212,0 @@

'use strict';
// Load modules
const Hoek = require('hoek');
const Hoek = require('hoek');
const Any = require('./types/any');

@@ -13,4 +12,2 @@ const Cast = require('./cast');

// Declare internals
const internals = {

@@ -28,2 +25,3 @@ alternatives: require('./types/alternatives'),

internals.applyDefaults = function (schema) {

@@ -42,2 +40,3 @@

internals.root = function () {

@@ -436,3 +435,2 @@

module.exports = internals.root();
'use strict';
// Load modules
// Declare internals
const internals = {};

@@ -9,0 +4,0 @@

'use strict';
// Load modules
const Hoek = require('hoek');
// Declare internals
const internals = {};

@@ -11,0 +7,0 @@

'use strict';
// Load modules
const Joi = require('../');
// Declare internals
const internals = {};
exports.options = Joi.object({

@@ -13,0 +10,0 @@ abortEarly: Joi.boolean(),

@@ -5,2 +5,6 @@ 'use strict';

const internals = {};
module.exports = class Set {

@@ -7,0 +11,0 @@

'use strict';
// Load modules
const Hoek = require('hoek');
const Hoek = require('hoek');
const Any = require('../any');

@@ -11,4 +10,2 @@ const Cast = require('../../cast');

// Declare internals
const internals = {};

@@ -15,0 +12,0 @@

'use strict';
// Load modules
const Hoek = require('hoek');
const Hoek = require('hoek');
const Ref = require('../../ref');

@@ -12,4 +11,2 @@ const Errors = require('../../errors');

// Declare internals
const internals = {

@@ -16,0 +13,0 @@ Set: require('../../set')

'use strict';
// Load modules
const Hoek = require('hoek');

@@ -8,7 +8,4 @@ const Any = require('../any');

const Ref = require('../../ref');
const Hoek = require('hoek');
// Declare internals
const internals = {};

@@ -15,0 +12,0 @@

'use strict';
// Load modules
const Hoek = require('hoek');
const Any = require('../any');
const Hoek = require('hoek');
// Declare internals
const internals = {};

@@ -32,3 +29,3 @@

try {
result.value = new Buffer(value, this._flags.encoding);
result.value = Buffer.from(value, this._flags.encoding);
}

@@ -35,0 +32,0 @@ catch (e) {

'use strict';
// Load modules
const Hoek = require('hoek');
const Any = require('../any');
const Hoek = require('hoek');
// Declare internals
const internals = {

@@ -12,0 +9,0 @@ Set: require('../../set')

'use strict';
// Load modules
const Hoek = require('hoek');
const Any = require('../any');
const Ref = require('../../ref');
const Hoek = require('hoek');
// Declare internals
const internals = {};
internals.isoDate = /^(?:[-+]\d{2})?(?:\d{4}(?!\d{2}\b))(?:(-?)(?:(?:0[1-9]|1[0-2])(?:\1(?:[12]\d|0[1-9]|3[01]))?|W(?:[0-4]\d|5[0-2])(?:-?[1-7])?|(?:00[1-9]|0[1-9]\d|[12]\d{2}|3(?:[0-5]\d|6[1-6])))(?![T]$|[T][\d]+Z$)(?:[T\s](?:(?:(?:[01]\d|2[0-3])(?:(:?)[0-5]\d)?|24\:?00)(?:[.,]\d+(?!:))?)(?:\2[0-5]\d(?:[.,]\d+)?)?(?:[Z]|(?:[+-])(?:[01]\d|2[0-3])(?::?[0-5]\d)?)?)?)?$/;

@@ -26,2 +24,3 @@ internals.invalidDate = new Date('');

internals.Date = class extends Any {

@@ -28,0 +27,0 @@

'use strict';
// Load modules
const Hoek = require('hoek');
const Hoek = require('hoek');
const ObjectType = require('../object');

@@ -10,4 +9,2 @@ const Ref = require('../../ref');

// Declare internals
const internals = {};

@@ -14,0 +11,0 @@

'use strict';
// Load modules
const Hoek = require('hoek');
const Any = require('../any');
const Hoek = require('hoek');
// Declare internals
const internals = {};

@@ -12,0 +9,0 @@

'use strict';
// Load modules
const Hoek = require('hoek');
const Any = require('../any');
const Ref = require('../../ref');
const Hoek = require('hoek');
// Declare internals
const internals = {

@@ -13,0 +10,0 @@ precisionRx: /(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/

'use strict';
// Load modules
const Hoek = require('hoek');
const Topo = require('topo');
const Any = require('../any');

@@ -12,4 +11,2 @@ const Errors = require('../../errors');

// Declare internals
const internals = {};

@@ -16,0 +13,0 @@

'use strict';
// Load modules
const Net = require('net');
const Net = require('net');
const Address = require('@hapi/address');
const Hoek = require('hoek');
let Isemail; // Loaded on demand
const Any = require('../any');

@@ -14,3 +14,2 @@ const Ref = require('../../ref');

// Declare internals

@@ -34,2 +33,3 @@ const internals = {

internals.String = class extends Any {

@@ -173,38 +173,59 @@

email(isEmailOptions) {
email(validationOptions) {
if (isEmailOptions) {
Hoek.assert(typeof isEmailOptions === 'object', 'email options must be an object');
Hoek.assert(typeof isEmailOptions.checkDNS === 'undefined', 'checkDNS option is not supported');
Hoek.assert(typeof isEmailOptions.tldWhitelist === 'undefined' ||
typeof isEmailOptions.tldWhitelist === 'object', 'tldWhitelist must be an array or object');
Hoek.assert(
typeof isEmailOptions.minDomainAtoms === 'undefined' ||
Number.isSafeInteger(isEmailOptions.minDomainAtoms) &&
isEmailOptions.minDomainAtoms > 0,
'minDomainAtoms must be a positive integer'
);
Hoek.assert(
typeof isEmailOptions.errorLevel === 'undefined' ||
typeof isEmailOptions.errorLevel === 'boolean' ||
(
Number.isSafeInteger(isEmailOptions.errorLevel) &&
isEmailOptions.errorLevel >= 0
),
'errorLevel must be a non-negative integer or boolean'
);
}
if (validationOptions) {
Hoek.assert(typeof validationOptions === 'object', 'email options must be an object');
return this._test('email', isEmailOptions, function (value, state, options) {
// Migration validation for unsupported options
Isemail = Isemail || require('isemail');
Hoek.assert(validationOptions.checkDNS === undefined, 'checkDNS option is not supported');
Hoek.assert(validationOptions.errorLevel === undefined, 'errorLevel option is not supported');
Hoek.assert(validationOptions.minDomainAtoms === undefined, 'minDomainAtoms option is not supported, use minDomainSegments instead');
Hoek.assert(validationOptions.tldBlacklist === undefined, 'tldBlacklist option is not supported, use tlds.deny instead');
Hoek.assert(validationOptions.tldWhitelist === undefined, 'tldWhitelist option is not supported, use tlds.allow instead');
try {
const result = Isemail.validate(value, isEmailOptions);
if (result === true || result === 0) {
return value;
}
// Validate options
if (validationOptions.tlds &&
typeof validationOptions.tlds === 'object') {
Hoek.assert(validationOptions.tlds.allow === undefined ||
validationOptions.tlds.allow === false ||
validationOptions.tlds.allow === true ||
Array.isArray(validationOptions.tlds.allow) ||
validationOptions.tlds.allow instanceof Set, 'tlds.allow must be an array, Set, or boolean');
Hoek.assert(validationOptions.tlds.deny === undefined ||
Array.isArray(validationOptions.tlds.deny) ||
validationOptions.tlds.deny instanceof Set, 'tlds.deny must be an array or Set');
const normalizeTable = (table, name) => {
if (table === undefined ||
typeof table === 'boolean' ||
table instanceof Set) {
return table;
}
return new Set(table);
};
validationOptions = Object.assign({}, validationOptions); // Shallow cloned
validationOptions.tlds = {
allow: normalizeTable(validationOptions.tlds.allow),
deny: normalizeTable(validationOptions.tlds.deny)
};
}
catch (e) { }
Hoek.assert(validationOptions.minDomainSegments === undefined ||
Number.isSafeInteger(validationOptions.minDomainSegments) && validationOptions.minDomainSegments > 0, 'minDomainSegments must be a positive integer');
}
return this._test('email', validationOptions, function (value, state, options) {
if (Address.email.isValid(value, validationOptions)) {
return value;
}
return this.createError('string.email', { value }, state, options);

@@ -211,0 +232,0 @@ });

'use strict';
// Load modules
const RFC3986 = require('./rfc3986');
// Declare internals
const internals = {

@@ -11,0 +7,0 @@ Ip: {

'use strict';
// Load modules
// Delcare internals
const internals = {

@@ -9,0 +4,0 @@ rfc3986: {}

'use strict';
// Load Modules
const RFC3986 = require('./rfc3986');
// Declare internals
const internals = {

@@ -45,3 +41,2 @@ Uri: {

module.exports = internals.Uri;
{
"name": "joi",
"description": "Object schema validation",
"version": "12.0.0",
"version": "12.1.1",
"homepage": "https://github.com/hapijs/joi",
"repository": "git://github.com/hapijs/joi",
"engines": {
"node": ">=6.0.0"
},
"main": "lib/index.js",

@@ -13,22 +16,16 @@ "keywords": [

],
"engines": {
"node": ">=4.0.0"
},
"dependencies": {
"@hapi/address": "1.x.x",
"hoek": "4.x.x",
"isemail": "3.x.x",
"topo": "2.x.x"
},
"devDependencies": {
"hapitoc": "1.x.x",
"code": "4.x.x",
"lab": "14.x.x"
},
"scripts": {
"test": "lab -t 100 -a code -L",
"test-debug": "lab -a code",
"test-cov-html": "lab -r html -o coverage.html -a code",
"toc": "hapitoc",
"version": "npm run toc && git add API.md README.md"
"test": "lab -t 100 -a code -L -l",
"test-cov-html": "lab -r html -o coverage.html -a code -l"
},
"license": "BSD-3-Clause"
"license": "SEE LICENSE IN LICENSE.md"
}

@@ -1,22 +0,11 @@

![joi Logo](https://raw.github.com/hapijs/joi/master/images/joi.png)
# joi
Object schema description language and validator for JavaScript objects.
[![npm version](https://badge.fury.io/js/joi.svg)](http://badge.fury.io/js/joi)
[![Build Status](https://secure.travis-ci.org/hapijs/joi.svg?branch=master)](http://travis-ci.org/hapijs/joi)
<!--
[![Build Status](https://travis-ci.org/hapijs/joi.svg?branch=v12-commercial)](https://travis-ci.org/hapijs/joi)
Remove those badges until they work properly on semver.
## License
[![Dependencies Status](https://david-dm.org/hapijs/joi.svg)](https://david-dm.org/hapijs/joi)
[![DevDependencies Status](https://david-dm.org/hapijs/joi/dev-status.svg)](https://david-dm.org/hapijs/joi#info=devDependencies)
This version of the package requires a commercial license. You may not use, copy, or distribute it without first acquiring a commercial license from Sideway Inc. Using this software without a license is a violation of US and international law. To obtain a license, please contact [sales@sideway.com](mailto:sales@sideway.com). The open source version of this package can be found [here](https://github.com/hapijs/joi).
-->
[![NSP Status](https://nodesecurity.io/orgs/hapijs/projects/0394bf83-b5bc-410b-878c-e8cf1b92033e/badge)](https://nodesecurity.io/orgs/hapijs/projects/0394bf83-b5bc-410b-878c-e8cf1b92033e)
[![Known Vulnerabilities](https://snyk.io/test/github/hapijs/joi/badge.svg)](https://snyk.io/test/github/hapijs/joi)
[![Join the chat at https://gitter.im/hapijs/joi](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/hapijs/joi?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Lead Maintainer: [Nicolas Morel](https://github.com/marsup)
# Introduction

@@ -29,4 +18,5 @@

# API
See the detailed [API Reference](https://github.com/hapijs/joi/blob/v12.0.0/API.md).
See the detailed [API Reference](https://github.com/hapijs/joi/blob/v12-commercial/API.md).
# Example

@@ -33,0 +23,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc