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.5.0 to 0.5.1

dist/util/reach.js

5

dist/array.js

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

// hi

@@ -42,6 +43,6 @@ var _Array = module.exports = SchemaObject.extend({

_validate: function(_value, _opts, _state){
var context = (_opts || {}).context || _state.parent
, subType, schema;
var context, subType, schema;
_state = _state || {}
context = _state.parent || (_opts || {}).context
schema = this._resolve(context)

@@ -48,0 +49,0 @@ subType = schema._subType

1

dist/boolean.js
'use strict';
var SchemaObject = require('./mixed')
, _ = require('lodash')
, locale = require('./locale.js').boolean

@@ -5,0 +4,0 @@

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

_resolve: function(context){
var schema = this;
return this._conditions.reduce(function(schema, match){

@@ -93,0 +92,0 @@ if(!context) throw new Error('missing the context necessary to cast this value')

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

if( this._nullable && value === null) return true
return value && typeof value === 'object' && !_.isArray(value)
return value && typeof value === 'object' && !Array.isArray(value)
},

@@ -74,6 +74,7 @@

_validate: function(_value, _opts, _state){
var schema;
var context, schema;
_state = _state || {}
schema = this._resolve(_opts, _state)
_state = _state || {}
context = _state.parent || (_opts || {}).context
schema = this._resolve(context)

@@ -167,4 +168,4 @@ return SchemaObject.prototype._validate

return _.size(dft) === 0 ? undefined : dft
return Object.keys(dft).length === 0 ? undefined : dft
}

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

file.contents = new Buffer(converted.code);
this.emit('data', file);

@@ -71,0 +72,0 @@ }

'use strict';
var mixed = require('./dist/mixed')
//, dynamic = require('./dist/dynamic');
, bool = require('./dist/boolean');

@@ -9,18 +9,9 @@ module.exports = {

number: require('./dist/number'),
boolean: require('./dist/boolean'),
boolean: bool,
bool: bool,
date: require('./dist/date'),
object: require('./dist/object'),
array: require('./dist/array')
array: require('./dist/array'),
reach: require('./dist/util/reach')
}
/*
schema.validate(val, opts)
.then(function(result){
result.isValid
result.errors
})
*/

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

_validate: function(_value, _opts, _state){
var context = (_opts || {}).context || _state.parent
, subType, schema;
var context, subType, schema;
_state = _state || {}
context = _state.parent || (_opts || {}).context
schema = this._resolve(context)

@@ -48,0 +48,0 @@ subType = schema._subType

'use strict';
var SchemaObject = require('./mixed')
, _ = require('lodash')
, locale = require('./locale.js').boolean

@@ -5,0 +4,0 @@

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

_resolve: function(context){
var schema = this;
return this._conditions.reduce(function(schema, match){

@@ -93,0 +92,0 @@ if(!context) throw new Error('missing the context necessary to cast this value')

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

if( this._nullable && value === null) return true
return value && typeof value === 'object' && !_.isArray(value)
return value && typeof value === 'object' && !Array.isArray(value)
},

@@ -74,6 +74,7 @@

_validate: function(_value, _opts, _state){
var schema;
var context, schema;
_state = _state || {}
schema = this._resolve(_opts, _state)
_state = _state || {}
context = _state.parent || (_opts || {}).context
schema = this._resolve(context)

@@ -167,4 +168,4 @@ return SchemaObject.prototype._validate

return _.size(dft) === 0 ? undefined : dft
return Object.keys(dft).length === 0 ? undefined : dft
}
{
"name": "yup",
"version": "0.5.0",
"version": "0.5.1",
"description": "Dead simple Object schema validation",

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

@@ -48,2 +48,27 @@ Yup

### `yup`
The module export.
```js
var yup = require('yup')
yup.mixed
yup.string
yup.number
yup.bool
yup.boolean
yup.date
yup.object
yup.array
yup.reach
```
### `.reach(Schema schema, String path, Object options)`
For nested schema's `yup.reach` will retrieve a nested schema based on the provided path.
### `mixed`

@@ -50,0 +75,0 @@

@@ -208,2 +208,36 @@ 'use strict';

it('should handle nested conditionals', function(){
var countSchema = number().when('isBig', { is: true, then: number().min(5) })
, inst = object().shape({
other: bool(),
stats: object({
isBig: bool(),
count: countSchema
})
.when('other', { is: true, then: object().required() })
})
return Promise.all([
inst.validate({ stats: undefined, other: true }).should.be.rejected
.then(function(err){
err.errors[0].should.contain('required')
}),
inst.validate({ stats: { isBig: true, count: 3 }, other: true }).should.be.rejected
.then(function(err){
err.errors[0].should.contain('must be at least 5')
}),
inst.validate({ stats: { isBig: true, count: 10 }, other: true }).should.be.fulfilled
.then(function(value){
value.should.deep.equal({ stats: { isBig: true, count: 10 }, other: true })
}),
countSchema.validate(10, { context: { isBig: true } }).should.be.fulfilled
.then(function(value){
value.should.deep.equal(10)
}),
])
})
it('should camelCase keys', function(){

@@ -210,0 +244,0 @@ var inst = object().shape({

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