Comparing version 0.16.3 to 0.16.4
@@ -0,1 +1,8 @@ | ||
v0.16.4 - Sat, 09 Apr 2016 20:13:13 GMT | ||
--------------------------------------- | ||
- [f30d1e3](../../commit/f30d1e3) [fixed] bug in date min/max with ref | ||
v0.16.3 - Thu, 07 Apr 2016 19:13:23 GMT | ||
@@ -2,0 +9,0 @@ --------------------------------------- |
@@ -7,2 +7,3 @@ 'use strict'; | ||
var isAbsent = require('./util/isAbsent'); | ||
var Ref = require('./util/reference'); | ||
@@ -41,5 +42,8 @@ var _require = require('./util/_'); | ||
min: function min(_min, msg) { | ||
var limit = this.cast(_min); | ||
var limit = _min; | ||
if (!this._typeCheck(limit)) throw new TypeError('`min` must be a Date or a value that can be `cast()` to a Date'); | ||
if (!Ref.isRef(limit)) { | ||
limit = this.cast(_min); | ||
if (!this._typeCheck(limit)) throw new TypeError('`min` must be a Date or a value that can be `cast()` to a Date'); | ||
} | ||
@@ -57,5 +61,8 @@ return this.test({ | ||
max: function max(_max, msg) { | ||
var limit = this.cast(_max); | ||
var limit = _max; | ||
if (!this._typeCheck(limit)) throw new TypeError('`max` must be a Date or a value that can be `cast()` to a Date'); | ||
if (!Ref.isRef(limit)) { | ||
limit = this.cast(_max); | ||
if (!this._typeCheck(limit)) throw new TypeError('`max` must be a Date or a value that can be `cast()` to a Date'); | ||
} | ||
@@ -62,0 +69,0 @@ return this.test({ |
{ | ||
"name": "yup", | ||
"version": "0.16.3", | ||
"version": "0.16.4", | ||
"description": "Dead simple Object schema validation", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -6,2 +6,3 @@ 'use strict'; | ||
, isAbsent = require('./util/isAbsent') | ||
, Ref = require('./util/reference') | ||
, { isDate, inherits } = require('./util/_'); | ||
@@ -36,6 +37,9 @@ | ||
min(min, msg){ | ||
var limit = this.cast(min); | ||
var limit = min; | ||
if(!this._typeCheck(limit)) | ||
throw new TypeError('`min` must be a Date or a value that can be `cast()` to a Date') | ||
if (!Ref.isRef(limit)) { | ||
limit = this.cast(min) | ||
if (!this._typeCheck(limit)) | ||
throw new TypeError('`min` must be a Date or a value that can be `cast()` to a Date') | ||
} | ||
@@ -46,3 +50,3 @@ return this.test({ | ||
message: msg || locale.min, | ||
params: { min: min }, | ||
params: { min }, | ||
test(value) { | ||
@@ -55,6 +59,9 @@ return isAbsent(value) || value >= this.resolve(limit) | ||
max(max, msg){ | ||
var limit = this.cast(max); | ||
var limit = max; | ||
if(!this._typeCheck(limit)) | ||
throw new TypeError('`max` must be a Date or a value that can be `cast()` to a Date') | ||
if (!Ref.isRef(limit)) { | ||
limit = this.cast(max) | ||
if (!this._typeCheck(limit)) | ||
throw new TypeError('`max` must be a Date or a value that can be `cast()` to a Date') | ||
} | ||
@@ -65,3 +72,3 @@ return this.test({ | ||
message: msg || locale.max, | ||
params: { max: max }, | ||
params: { max }, | ||
test(value) { | ||
@@ -68,0 +75,0 @@ return isAbsent(value) || value <= this.resolve(limit) |
@@ -5,3 +5,3 @@ 'use strict'; | ||
, Promise = require('promise/src/es6-extensions') | ||
, date = require('../src/date'); | ||
, { ref, date } = require('../src'); | ||
@@ -60,26 +60,46 @@ chai.use(chaiAsPromised); | ||
it('should check MIN correctly', function(){ | ||
var v = date().min(new Date(2014, 3, 15)); | ||
var min = new Date(2014, 3, 15) | ||
, invalid = new Date(2014, 1, 15) | ||
, valid = new Date(2014, 5, 15) | ||
;(function(){ date().max('hello') }).should.throw(TypeError) | ||
;(function(){ date().max(ref('$foo')) }).should.not.throw | ||
return Promise.all([ | ||
v.isValid(new Date(2014, 5, 15)).should.eventually.equal(true), | ||
v.isValid(new Date(2014, 1, 15)).should.eventually.equal(false), | ||
date().min(min).isValid(valid).should.eventually.equal(true), | ||
date().min(min).isValid(invalid).should.eventually.equal(false), | ||
date().min(min).isValid(null).should.eventually.equal(false), | ||
v.isValid(null).should.eventually.equal(false) | ||
date().min(ref('$foo')) | ||
.isValid(valid, { context: { foo: min }}) | ||
.should.eventually.equal(true), | ||
date().min(ref('$foo')) | ||
.isValid(invalid, { context: { foo: min }}) | ||
.should.eventually.equal(false) | ||
]) | ||
}) | ||
it('should check MAX correctly', function(){ | ||
var v = date().max(new Date(2014, 7, 15)); | ||
it('should check MAX correctly', function() { | ||
var max = new Date(2014, 7, 15) | ||
, invalid = new Date(2014, 9, 15) | ||
, valid = new Date(2014, 5, 15) | ||
;(function(){ date().max('hello') }).should.throw(TypeError) | ||
;(function(){ date().max(ref('$foo')) }).should.not.throw | ||
return Promise.all([ | ||
v.isValid(new Date(2014, 5, 15)).should.eventually.equal(true), | ||
v.isValid(new Date(2014, 9, 15)).should.eventually.equal(false), | ||
v.nullable(true).isValid(null).should.eventually.equal(true) | ||
date().max(max).isValid(valid).should.eventually.equal(true), | ||
date().max(max).isValid(invalid).should.eventually.equal(false), | ||
date().max(max) | ||
.nullable(true) | ||
.isValid(null).should.eventually.equal(true), | ||
date().max(ref('$foo')) | ||
.isValid(valid, { context: { foo: max }}) | ||
.should.eventually.equal(true), | ||
date().max(ref('$foo')) | ||
.isValid(invalid, { context: { foo: max }}) | ||
.should.eventually.equal(false) | ||
]) | ||
}) | ||
}) | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
371498
9697