occamsrazor-match
Advanced tools
Comparing version 4.0.0 to 4.1.0
var arrayOf = require('./arrayOf'); | ||
module.exports = function some(args) { | ||
module.exports = function every(args) { | ||
return arrayOf(args, false); | ||
}; |
{ | ||
"name": "occamsrazor-match", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "helper library for writing validators", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -37,2 +37,4 @@ occamsrazor-match | ||
var every = require('occamsrazor-match/extra/every'); | ||
var someValues = require('occamsrazor-match/extra/someValues'); | ||
var everyValues = require('occamsrazor-match/extra/everyValues'); | ||
var greaterThan = require('occamsrazor-match/extra/greaterThan'); | ||
@@ -185,5 +187,5 @@ var lessThan = require('occamsrazor-match/extra/lessThan'); | ||
some/every | ||
========== | ||
This couple of validators can be used to validate arrays. It takes a validator as argument (it uses "match" behind the scene) and checks the array items against that validator. In the case of "some", at least a check should pass to return true. In the case of "every", all of them should pass. | ||
some/every and someValues/everyValues | ||
===================================== | ||
some/every validates arrays. It takes a validator as argument (it uses "match" behind the scene) and checks the array items against that validator. In the case of "some", at least a check should pass to return true. In the case of "every", all of them should pass. | ||
```js | ||
@@ -201,2 +203,3 @@ var atLeastOne5 = some(5); | ||
``` | ||
someValues and everyValues do the same on all values of an object. | ||
@@ -203,0 +206,0 @@ greaterThan, lessThan |
@@ -11,2 +11,4 @@ var assert = require('chai').assert; | ||
var some = require('../extra/some'); | ||
var everyValues = require('../extra/everyValues'); | ||
var someValues = require('../extra/someValues'); | ||
var isUndefined = require('../extra/isUndefined'); | ||
@@ -120,7 +122,7 @@ var greaterThan = require('../extra/greaterThan'); | ||
describe('arrayOf', function () { | ||
describe('every', function () { | ||
var areFive; | ||
before(function () { | ||
areFive = arrayOf(5); | ||
areFive = every(5); | ||
}); | ||
@@ -143,53 +145,93 @@ | ||
}); | ||
it('must not match (3)', function () { | ||
assert.isTrue(areFive([])); | ||
}); | ||
}); | ||
describe('every', function () { | ||
describe('some', function () { | ||
var someFive; | ||
before(function () { | ||
someFive = some(5); | ||
}); | ||
it('must match', function () { | ||
assert.isTrue(someFive([5])); | ||
}); | ||
it('must match (2)', function () { | ||
assert.isTrue(someFive([5, 5])); | ||
}); | ||
it('must not match', function () { | ||
assert.isFalse(someFive([3])); | ||
}); | ||
it('must not match (2)', function () { | ||
assert.isTrue(someFive([5, 3])); | ||
}); | ||
it('must not match (3)', function () { | ||
assert.isTrue(someFive([3, 5])); | ||
}); | ||
it('must not match (4)', function () { | ||
assert.isFalse(someFive([])); | ||
}); | ||
}); | ||
describe('everyValues', function () { | ||
var areFive; | ||
before(function () { | ||
areFive = every(5); | ||
areFive = everyValues(5); | ||
}); | ||
it('must match', function () { | ||
assert.isTrue(areFive([5])); | ||
assert.isTrue(areFive({v: 5})); | ||
}); | ||
it('must match (2)', function () { | ||
assert.isTrue(areFive([5, 5])); | ||
assert.isTrue(areFive({ v: 5, v1: 5 })); | ||
}); | ||
it('must not match', function () { | ||
assert.isFalse(areFive([3])); | ||
assert.isFalse(areFive({ v: 3 })); | ||
}); | ||
it('must not match (2)', function () { | ||
assert.isFalse(areFive([5, 3])); | ||
assert.isFalse(areFive({ v: 5, v1: 3 })); | ||
}); | ||
it('must not match (3)', function () { | ||
assert.isTrue(areFive({})); | ||
}); | ||
}); | ||
describe('some', function () { | ||
describe('someValues', function () { | ||
var someFive; | ||
before(function () { | ||
someFive = some(5); | ||
someFive = someValues(5); | ||
}); | ||
it('must match', function () { | ||
assert.isTrue(someFive([5])); | ||
assert.isTrue(someFive({ v: 5 })); | ||
}); | ||
it('must match (2)', function () { | ||
assert.isTrue(someFive([5, 5])); | ||
assert.isTrue(someFive({ v: 5, v1: 5 })); | ||
}); | ||
it('must not match', function () { | ||
assert.isFalse(someFive([3])); | ||
assert.isFalse(someFive({ v: 3 })); | ||
}); | ||
it('must not match (2)', function () { | ||
assert.isTrue(someFive([5, 3])); | ||
assert.isTrue(someFive({ v: 5, v1: 3 })); | ||
}); | ||
it('must not match (3)', function () { | ||
assert.isTrue(someFive([3, 5])); | ||
assert.isFalse(someFive({})); | ||
}); | ||
@@ -196,0 +238,0 @@ }); |
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
43660
37
1019
345