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.7.5 to 0.8.0

6

lib/mixed.js

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

var result = schema.tests.map(function (fn) {
return fn.call(schema, value, path);
return fn.call(schema, value, path, context);
});

@@ -263,7 +263,7 @@

function validate(value, path) {
function validate(value, path, context) {
var _this2 = this;
return new Promise(function (resolve, reject) {
!opts.useCallback ? resolve(opts.test.call(_this2, value)) : opts.test.call(_this2, value, function (err, valid) {
!opts.useCallback ? resolve(opts.test.call(_this2, value, context)) : opts.test.call(_this2, value, context, function (err, valid) {
return err ? reject(err) : resolve(valid);

@@ -270,0 +270,0 @@ });

{
"name": "yup",
"version": "0.7.5",
"version": "0.8.0",
"description": "Dead simple Object schema validation",

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

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

let result = schema.tests.map(fn => fn.call(schema, value, path))
let result = schema.tests.map(fn => fn.call(schema, value, path, context))

@@ -252,7 +252,7 @@ result = endEarly

function validate(value, path) {
function validate(value, path, context) {
return new Promise((resolve, reject) => {
!opts.useCallback
? resolve(opts.test.call(this, value))
: opts.test.call(this, value, (err, valid) => err ? reject(err) : resolve(valid))
? resolve(opts.test.call(this, value, context))
: opts.test.call(this, value, context, (err, valid) => err ? reject(err) : resolve(valid))
})

@@ -259,0 +259,0 @@ .then(valid => {

@@ -129,3 +129,20 @@ 'use strict';

it.only('tests should receive context', function(done){
var inst = object({
other: mixed(),
test: mixed().test({
message: 'invalid',
exclusive: true,
name: 'max',
test: function(v, context){
context.should.eql({ other: 5, test : 'hi' })
done()
}
})
})
inst.validate({ other: 5, test : 'hi' })
})
it('should allow custom validation of either style', function(){

@@ -136,3 +153,3 @@ var inst = string()

})
.test('name', 'test b', function(val, done){
.test('name', 'test b', function(val, context, done){
process.nextTick(function(){

@@ -139,0 +156,0 @@ done(null, val !== 'jim')

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