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

yup

Package Overview
Dependencies
Maintainers
1
Versions
127
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yup - npm Package Compare versions

Comparing version 0.14.0 to 0.14.1

7

CHANGELOG.md

@@ -0,1 +1,8 @@

v0.14.1 - Tue, 16 Feb 2016 19:51:25 GMT
---------------------------------------
- [ff19720](../../commit/ff19720) [fixed] noUnknown and stripUnknown work and propagate to children
v0.14.0 - Mon, 08 Feb 2016 16:17:40 GMT

@@ -2,0 +9,0 @@ ---------------------------------------

15

lib/object.js

@@ -103,2 +103,4 @@ 'use strict';

schema.withMutation(function () {
var innerOptions = _extends({}, _opts, { context: {} });
value = transform(props, function (obj, prop) {

@@ -110,3 +112,3 @@ var exists = has(value, prop);

obj[prop] = fieldSchema.cast(value[prop], { context: obj });
obj[prop] = fieldSchema.cast(value[prop], innerOptions);
} else if (exists && !strip) obj[prop] = value[prop];else if (fields[prop]) {

@@ -117,3 +119,3 @@ var fieldDefault = fields[prop]['default'] ? fields[prop]['default']() : undefined;

}
}, {});
}, innerOptions.context);

@@ -210,3 +212,6 @@ delete schema._default;

noUnknown: function noUnknown(noAllow, message) {
noUnknown: function noUnknown() {
var noAllow = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0];
var message = arguments.length <= 1 || arguments[1] === undefined ? locale.noUnknown : arguments[1];
if (typeof noAllow === 'string') message = noAllow, noAllow = true;

@@ -217,3 +222,3 @@

exclusive: true,
message: message || locale.noUnknown,
message: message,
test: function test(value) {

@@ -224,3 +229,3 @@ return value == null || !noAllow || unknown(this.schema, value).length === 0;

if (noAllow) this._options.stripUnknown = true;
if (noAllow) next._options.stripUnknown = true;

@@ -227,0 +232,0 @@ return next;

{
"name": "yup",
"version": "0.14.0",
"version": "0.14.1",
"description": "Dead simple Object schema validation",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -95,2 +95,4 @@ 'use strict';

schema.withMutation(() => {
let innerOptions = { ..._opts, context: {} };
value = transform(props, function(obj, prop) {

@@ -102,3 +104,3 @@ var exists = has(value, prop);

obj[prop] = fieldSchema.cast(value[prop], { context: obj })
obj[prop] = fieldSchema.cast(value[prop], innerOptions)
}

@@ -114,3 +116,3 @@ else if (exists && !strip)

}
}, {})
}, innerOptions.context)

@@ -207,4 +209,4 @@ delete schema._default

noUnknown(noAllow, message) {
if ( typeof noAllow === 'string')
noUnknown(noAllow = true, message = locale.noUnknown) {
if (typeof noAllow === 'string')
message = noAllow, noAllow = true;

@@ -215,3 +217,3 @@

exclusive: true,
message: message || locale.noUnknown,
message: message,
test(value) {

@@ -222,6 +224,6 @@ return value == null || !noAllow || unknown(this.schema, value).length === 0

if ( noAllow )
this._options.stripUnknown = true
if (noAllow)
next._options.stripUnknown = true
return next
return next
},

@@ -228,0 +230,0 @@

@@ -145,2 +145,20 @@ 'use strict';

it('should pass options to children', function() {
object({
names: object({
first: string()
})
})
.cast({
extra: true,
names: { first: 'john', extra: true }
}, { stripUnknown: true }
)
.should.eql({
names: {
first: 'john'
}
})
})
it('should call shape with constructed with an arg', function(){

@@ -200,9 +218,18 @@ var inst = object({

})
return Promise.all([
inst
.noUnknown('hi')
.validate({ extra: 'field' }, { strict: true }).should.be.rejected
.then(function(err){
err.errors[0].should.equal('hi')
}),
return inst.validate({ extra: 'field' })
.should.be.rejected
.then(function(err){
err.errors[0].should.equal('hi')
})
inst
.noUnknown()
.validate({ extra: 'field' }, { strict: true }).should.be.rejected
.then(function(err){
err.errors[0].should.be.a('string')
})
])
})

@@ -212,5 +239,5 @@

var inst = object().shape({
prop: mixed(),
other: mixed()
})
prop: mixed(),
other: mixed()
})

@@ -334,3 +361,3 @@ inst = inst.test('test', '${path} oops', function(){

var inst = object().shape({
myProp: mixed(),
myProp: mixed()
})

@@ -393,3 +420,3 @@ .from('prop', 'myProp')

var inst = object().shape({
other: bool(),
other: bool()
})

@@ -396,0 +423,0 @@ .default(undefined)

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