Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

joi

Package Overview
Dependencies
Maintainers
4
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 10.4.1 to 10.4.2

20

lib/alternatives.js

@@ -30,3 +30,3 @@ 'use strict';

const il = this._inner.matches.length;
const baseType = this._settings && this._settings.baseType;
const baseType = this._baseType;

@@ -43,10 +43,11 @@ for (let i = 0; i < il; ++i) {

}
else if (baseType && i === (il - 1)) {
return baseType._validate(value, state, options);
}
}
else if (item.then || baseType) {
return (item.then || baseType)._validate(value, state, options);
else if (item.then) {
return item.then._validate(value, state, options);
}
if (i === (il - 1) && baseType) {
return baseType._validate(value, state, options);
}
continue;

@@ -112,5 +113,6 @@ }

if (obj._settings && obj._settings.baseType) {
item.then = item.then && obj._settings.baseType.concat(item.then);
item.otherwise = item.otherwise && obj._settings.baseType.concat(item.otherwise);
if (obj._baseType) {
item.then = item.then && obj._baseType.concat(item.then);
item.otherwise = item.otherwise && obj._baseType.concat(item.otherwise);
}

@@ -117,0 +119,0 @@

@@ -100,2 +100,3 @@ 'use strict';

obj._settings = internals.concatSettings(this._settings);
obj._baseType = this._baseType;
obj._valids = Hoek.clone(this._valids);

@@ -387,3 +388,3 @@ obj._invalids = Hoek.clone(this._invalids);

obj._flags.presence = 'ignore';
obj._settings = internals.concatSettings(obj._settings, { baseType: this });
obj._baseType = this;

@@ -475,33 +476,31 @@ return obj;

if (!this._flags.strip) {
if (value !== undefined) {
finalValue = this._flags.raw ? originalValue : value;
}
else if (options.noDefaults) {
finalValue = value;
}
else if (Ref.isRef(this._flags.default)) {
finalValue = this._flags.default(state.parent, options);
}
else if (typeof this._flags.default === 'function' &&
!(this._flags.func && !this._flags.default.description)) {
if (value !== undefined) {
finalValue = this._flags.raw ? originalValue : value;
}
else if (options.noDefaults) {
finalValue = value;
}
else if (Ref.isRef(this._flags.default)) {
finalValue = this._flags.default(state.parent, options);
}
else if (typeof this._flags.default === 'function' &&
!(this._flags.func && !this._flags.default.description)) {
let args;
let args;
if (state.parent !== null &&
this._flags.default.length > 0) {
if (state.parent !== null &&
this._flags.default.length > 0) {
args = [Hoek.clone(state.parent), options];
}
args = [Hoek.clone(state.parent), options];
}
const defaultValue = internals._try(this._flags.default, args);
finalValue = defaultValue.value;
if (defaultValue.error) {
errors.push(this.createError('any.default', defaultValue.error, state, options));
}
const defaultValue = internals._try(this._flags.default, args);
finalValue = defaultValue.value;
if (defaultValue.error) {
errors.push(this.createError('any.default', defaultValue.error, state, options));
}
else {
finalValue = Hoek.clone(this._flags.default);
}
}
else {
finalValue = Hoek.clone(this._flags.default);
}

@@ -526,3 +525,4 @@ if (errors.length && typeof this._flags.error === 'function') {

return {
value: finalValue,
value: this._flags.strip ? undefined : finalValue,
finalValue,
errors: errors.length ? errors : null

@@ -712,2 +712,10 @@ };

if (this._settings) {
description.options = Hoek.clone(this._settings);
}
if (this._baseType) {
description.base = this._baseType.describe();
}
if (this._description) {

@@ -714,0 +722,0 @@ description.description = this._description;

@@ -393,3 +393,3 @@ 'use strict';

Hoek.assert(Hoek.isInteger(limit) && limit >= 0, 'limit must be a positive integer');
Hoek.assert(Number.isSafeInteger(limit) && limit >= 0, 'limit must be a positive integer');

@@ -408,3 +408,3 @@ return this._test('min', limit, function (value, state, options) {

Hoek.assert(Hoek.isInteger(limit) && limit >= 0, 'limit must be a positive integer');
Hoek.assert(Number.isSafeInteger(limit) && limit >= 0, 'limit must be a positive integer');

@@ -423,3 +423,3 @@ return this._test('max', limit, function (value, state, options) {

Hoek.assert(Hoek.isInteger(limit) && limit >= 0, 'limit must be a positive integer');
Hoek.assert(Number.isSafeInteger(limit) && limit >= 0, 'limit must be a positive integer');

@@ -426,0 +426,0 @@ return this._test('length', limit, function (value, state, options) {

@@ -57,3 +57,3 @@ 'use strict';

Hoek.assert(Hoek.isInteger(limit) && limit >= 0, 'limit must be a positive integer');
Hoek.assert(Number.isSafeInteger(limit) && limit >= 0, 'limit must be a positive integer');

@@ -72,3 +72,3 @@ return this._test('min', limit, function (value, state, options) {

Hoek.assert(Hoek.isInteger(limit) && limit >= 0, 'limit must be a positive integer');
Hoek.assert(Number.isSafeInteger(limit) && limit >= 0, 'limit must be a positive integer');

@@ -87,3 +87,3 @@ return this._test('max', limit, function (value, state, options) {

Hoek.assert(Hoek.isInteger(limit) && limit >= 0, 'limit must be a positive integer');
Hoek.assert(Number.isSafeInteger(limit) && limit >= 0, 'limit must be a positive integer');

@@ -90,0 +90,0 @@ return this._test('length', limit, function (value, state, options) {

@@ -113,3 +113,3 @@ 'use strict';

Hoek.assert(Hoek.isInteger(limit), 'limit must be an integer');
Hoek.assert(Number.isSafeInteger(limit), 'limit must be an integer');
Hoek.assert(!('precision' in this._flags), 'precision already set');

@@ -116,0 +116,0 @@

@@ -165,9 +165,11 @@ 'use strict';

}
if (child.schema._flags.strip || (result.value === undefined && result.value !== item)) {
stripProps.push(key);
else {
if (child.schema._flags.strip || (result.value === undefined && result.value !== item)) {
stripProps.push(key);
target[key] = result.finalValue;
}
else if (result.value !== undefined) {
target[key] = result.value;
}
}
else if (result.value !== undefined) {
target[key] = result.value;
}
}

@@ -342,3 +344,3 @@

Hoek.assert(Hoek.isInteger(limit) && limit >= 0, 'limit must be a positive integer');
Hoek.assert(Number.isSafeInteger(limit) && limit >= 0, 'limit must be a positive integer');

@@ -357,3 +359,3 @@ return this._test('length', limit, function (value, state, options) {

Hoek.assert(Hoek.isInteger(n) && n >= 0, 'n must be a positive integer');
Hoek.assert(Number.isSafeInteger(n) && n >= 0, 'n must be a positive integer');

@@ -372,3 +374,3 @@ return this._test('arity', n, function (value, state, options) {

Hoek.assert(Hoek.isInteger(n) && n > 0, 'n must be a strict positive integer');
Hoek.assert(Number.isSafeInteger(n) && n > 0, 'n must be a strict positive integer');

@@ -387,3 +389,3 @@ return this._test('minArity', n, function (value, state, options) {

Hoek.assert(Hoek.isInteger(n) && n >= 0, 'n must be a positive integer');
Hoek.assert(Number.isSafeInteger(n) && n >= 0, 'n must be a positive integer');

@@ -402,3 +404,3 @@ return this._test('maxArity', n, function (value, state, options) {

Hoek.assert(Hoek.isInteger(limit) && limit >= 0, 'limit must be a positive integer');
Hoek.assert(Number.isSafeInteger(limit) && limit >= 0, 'limit must be a positive integer');

@@ -417,3 +419,3 @@ return this._test('min', limit, function (value, state, options) {

Hoek.assert(Hoek.isInteger(limit) && limit >= 0, 'limit must be a positive integer');
Hoek.assert(Number.isSafeInteger(limit) && limit >= 0, 'limit must be a positive integer');

@@ -420,0 +422,0 @@ return this._test('max', limit, function (value, state, options) {

@@ -163,6 +163,6 @@ 'use strict';

Hoek.assert(typeof isEmailOptions.minDomainAtoms === 'undefined' ||
Hoek.isInteger(isEmailOptions.minDomainAtoms) && isEmailOptions.minDomainAtoms > 0,
Number.isSafeInteger(isEmailOptions.minDomainAtoms) && isEmailOptions.minDomainAtoms > 0,
'minDomainAtoms must be a positive integer');
Hoek.assert(typeof isEmailOptions.errorLevel === 'undefined' || typeof isEmailOptions.errorLevel === 'boolean' ||
(Hoek.isInteger(isEmailOptions.errorLevel) && isEmailOptions.errorLevel >= 0),
(Number.isSafeInteger(isEmailOptions.errorLevel) && isEmailOptions.errorLevel >= 0),
'errorLevel must be a non-negative integer or boolean');

@@ -537,3 +537,3 @@ }

Hoek.assert((Hoek.isInteger(limit) && limit >= 0) || isRef, 'limit must be a positive integer or reference');
Hoek.assert((Number.isSafeInteger(limit) && limit >= 0) || isRef, 'limit must be a positive integer or reference');
Hoek.assert(!encoding || Buffer.isEncoding(encoding), 'Invalid encoding:', encoding);

@@ -547,3 +547,3 @@

if (!Hoek.isInteger(compareTo)) {
if (!Number.isSafeInteger(compareTo)) {
return this.createError('string.ref', { ref: limit.key }, state, options);

@@ -550,0 +550,0 @@ }

{
"name": "joi",
"description": "Object schema validation",
"version": "10.4.1",
"version": "10.4.2",
"homepage": "https://github.com/hapijs/joi",

@@ -6,0 +6,0 @@ "repository": "git://github.com/hapijs/joi",

@@ -16,3 +16,3 @@ ![joi Logo](https://raw.github.com/hapijs/joi/master/images/joi.png)

[![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/npm/joi/badge.svg)](https://snyk.io/test/npm/joi)
[![Known Vulnerabilities](https://snyk.io/test/github/hapijs/joi/badge.svg)](https://snyk.io/test/github/hapijs/joi)

@@ -129,3 +129,3 @@ [![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)

# API
See the [API Reference](https://github.com/hapijs/joi/blob/v10.4.1/API.md).
See the [API Reference](https://github.com/hapijs/joi/blob/v10.4.2/API.md).

@@ -132,0 +132,0 @@ # Browsers

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