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

validate-promise

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

validate-promise - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

src/rules/equals.js

2

dist/index.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("validate-promise",[],t):"object"==typeof exports?exports["validate-promise"]=t():e["validate-promise"]=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="/",t(0)}([function(e,t,r){e.exports=r(1)},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.whitelist=t.required=t.lessthan=t.int=t.greaterthan=t.blacklist=t.before=t.after=void 0;var o=r(2),i=n(o),u=r(3),s=n(u),f=r(4),a=n(f),c=r(5),l=n(c),d=r(6),p=n(d),v=r(7),m=n(v),P=r(8),y=n(P),j=r(9),_=n(j),b=function(e){var t=Object.keys(e);return Promise.all(t.map(function(t){return Promise.resolve(e[t]).then(function(e){var r={state:"fulfilled",key:t,value:e};return r},function(e){var r={state:"rejected",key:t,reason:e};return r})}))},h=function(e,t){var r={};return console.log("validate contract",e),e.forEach(function(e,n){var o=e.key,i=t[o];e.promises.forEach(function(u,s){var f=o+"."+n+"."+s,a=void 0===u.arg?null:u.arg;r[f]=u.rule(i,t,e.msg,a)})}),console.log("promises",r),new Promise(function(e,t){b(r).then(function(r){var n=r.filter(function(e){return"rejected"===e.state}),o={};n.forEach(function(e){var t=e.key.split(".").shift();o[t]||(o[t]=[]),o[t].push(e.reason)}),0===n.length&&e(!0),t(o)})})};t.default=h,t.after=i.default,t.before=s.default,t.blacklist=a.default,t.greaterthan=l.default,t.int=p.default,t.lessthan=m.default,t.required=y.default,t.whitelist=_.default},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,n){var o=Date.parse(e);"function"==typeof n&&(n=n(e,t));var i=Date.parse(n);return o>i?Promise.resolve():Promise.reject(r(e,t,n))}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,n){var o=Date.parse(e);"function"==typeof n&&(n=n(e,t));var i=Date.parse(n);return o<i?Promise.resolve():Promise.reject(r(e,t,n))}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,n){return"function"==typeof n&&(n=n(e,t)),n.indexOf(e)===-1?Promise.resolve():Promise.reject(r(e,t,n))}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,n){return"function"==typeof n&&(n=n(e,t)),parseInt(e,10)>n?Promise.resolve():Promise.reject(r(e,t,n))}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,n){"function"==typeof n&&(n=n(e,t));var o=/^(?:[-+]?(?:0|[1-9][0-9]*))$/;if(null!==n){if(void 0!==n.min&&parseInt(e,10)<parseInt(n.min,10))return Promise.reject(r(e,t,n));if(n.max&&parseInt(e,10)>parseInt(n.max,10))return Promise.reject(r(e,t,n))}return o.test(e)?Promise.resolve():Promise.reject(r(e,t,n))}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,n){return"function"==typeof n&&(n=n(e,t)),parseInt(e,10)<n?Promise.resolve():Promise.reject(r(e,t,n))}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){return new Promise(function(n,o){return""!==e&&void 0!==e?n():o(r(e,t))})}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,n){return"function"==typeof n&&(n=n(e,t)),n.indexOf(e)!==-1?Promise.resolve():Promise.reject(r(e,t,n))}}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("validate-promise",[],t):"object"==typeof exports?exports["validate-promise"]=t():e["validate-promise"]=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="/",t(0)}([function(e,t,r){e.exports=r(1)},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.whitelist=t.required=t.lessthan=t.int=t.greaterthan=t.equals=t.blacklist=t.before=t.after=void 0;var o=r(2),u=n(o),i=r(3),s=n(i),f=r(4),a=n(f),c=r(5),l=n(c),d=r(6),p=n(d),v=r(7),m=n(v),P=r(8),y=n(P),j=r(9),_=n(j),b=r(10),h=n(b),x=function(e){var t=Object.keys(e);return Promise.all(t.map(function(t){return Promise.resolve(e[t]).then(function(e){var r={state:"fulfilled",key:t,value:e};return r},function(e){var r={state:"rejected",key:t,reason:e};return r})}))},O=function(e,t){var r={};return e.forEach(function(e,n){var o=e.key,u=t[o];e.promises.forEach(function(i,s){var f=o+"."+n+"."+s,a=void 0===i.arg?null:i.arg;r[f]=i.rule(u,t,e.msg,a)})}),new Promise(function(e,t){x(r).then(function(r){var n=r.filter(function(e){return"rejected"===e.state}),o={};n.forEach(function(e){var t=e.key.split(".").shift();o[t]||(o[t]=[]),o[t].push(e.reason)}),0===n.length&&e(!0),t(o)})})};t.default=O,t.after=u.default,t.before=s.default,t.blacklist=a.default,t.equals=l.default,t.greaterthan=p.default,t.int=m.default,t.lessthan=y.default,t.required=_.default,t.whitelist=h.default},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,n){var o=Date.parse(e);"function"==typeof n&&(n=n(e,t));var u=Date.parse(n);return o>u?Promise.resolve():Promise.reject(r(e,t,n))}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,n){var o=Date.parse(e);"function"==typeof n&&(n=n(e,t));var u=Date.parse(n);return o<u?Promise.resolve():Promise.reject(r(e,t,n))}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,n){return"function"==typeof n&&(n=n(e,t)),n.indexOf(e)===-1?Promise.resolve():Promise.reject(r(e,t,n))}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,n){return"function"==typeof n&&(n=n(e,t)),e==n?Promise.resolve():Promise.reject(r(e,t,n))}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,n){return"function"==typeof n&&(n=n(e,t)),parseInt(e,10)>n?Promise.resolve():Promise.reject(r(e,t,n))}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,n){"function"==typeof n&&(n=n(e,t));var o=/^(?:[-+]?(?:0|[1-9][0-9]*))$/;if(null!==n){if(void 0!==n.min&&parseInt(e,10)<parseInt(n.min,10))return Promise.reject(r(e,t,n));if(n.max&&parseInt(e,10)>parseInt(n.max,10))return Promise.reject(r(e,t,n))}return o.test(e)?Promise.resolve():Promise.reject(r(e,t,n))}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,n){return"function"==typeof n&&(n=n(e,t)),parseInt(e,10)<n?Promise.resolve():Promise.reject(r(e,t,n))}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){return new Promise(function(n,o){return""!==e&&void 0!==e?n():o(r(e,t))})}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,n){return"function"==typeof n&&(n=n(e,t)),n.indexOf(e)!==-1?Promise.resolve():Promise.reject(r(e,t,n))}}])});
//# sourceMappingURL=index.js.map
{
"name": "validate-promise",
"version": "2.0.1",
"version": "2.0.2",
"description": "Promised based validaation library",

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

@@ -97,4 +97,20 @@ # validation-promise

Validate that the supplied value is not contained within the argument black list.
### Equals
```javascript
contract = [
{
key: 'age',
promises: [
{
rule: equals,
arg: () => '17'
}
],
msg: (value, row, arg) => value + ' is not 17'
}];
```
Validate that the supplied value is is loosely equal to the argument.
### Greaterthan

@@ -101,0 +117,0 @@

@@ -6,2 +6,3 @@ // @flow

import blacklist from './rules/blacklist';
import equals from './rules/equals';
import greaterthan from './rules/greaterthan';

@@ -85,2 +86,3 @@ import int from './rules/int';

blacklist,
equals,
greaterthan,

@@ -87,0 +89,0 @@ int,

@@ -7,3 +7,4 @@ import {expect} from 'chai';

contract = [
{key: 'age',
{
key: 'age',
promises: [

@@ -17,3 +18,3 @@ {

}];
describe('isafter than success', done => {
describe('isafter success', done => {
beforeEach(done => {

@@ -32,3 +33,3 @@ let data = {

it('pass the validation', () => {
it('passes the validation', () => {
expect(res).to.equal(true);

@@ -38,3 +39,3 @@ });

describe('isafter than failed', done => {
describe('isafter failed', done => {
beforeEach(done => {

@@ -55,3 +56,3 @@ let data = {

it('fail the validation', () => {
it('fails the validation', () => {
expect(failed).to.be.an('object');

@@ -58,0 +59,0 @@ expect(failed).to.have.key('age');

@@ -7,3 +7,4 @@ import {expect} from 'chai';

contract = [
{key: 'age',
{
key: 'age',
promises: [{

@@ -30,3 +31,3 @@ rule: before,

it('pass the validation', () => {
it('passes the validation', () => {
expect(res).to.equal(true);

@@ -52,3 +53,3 @@ });

it('fail the validation', () => {
it('fails the validation', () => {
expect(failed).to.be.an('object');

@@ -55,0 +56,0 @@ expect(failed).to.have.key('age');

@@ -7,3 +7,4 @@ import {expect} from 'chai';

contract = [
{key: 'age',
{
key: 'age',
promises: [

@@ -31,3 +32,3 @@ {

it('pass the validation', () => {
it('passes the validation', () => {
expect(res).to.equal(true);

@@ -53,3 +54,3 @@ });

it('fail the validation', () => {
it('fails the validation', () => {
expect(failed).to.be.an('object');

@@ -56,0 +57,0 @@ expect(failed).to.have.key('age');

@@ -30,3 +30,3 @@ import {expect} from 'chai';

it('pass the validation', () => {
it('passes the validation', () => {
expect(res).to.equal(true);

@@ -52,3 +52,3 @@ });

it('fail the validation', () => {
it('fails the validation', () => {
expect(failed).to.be.an('object');

@@ -55,0 +55,0 @@ expect(failed).to.have.key('age');

@@ -37,3 +37,3 @@ import {expect} from 'chai';

it('pass the validation', () => {
it('passes the validation', () => {
expect(res).to.equal(true);

@@ -57,3 +57,3 @@ });

it('pass the validation', () => {
it('passes the validation', () => {
expect(resMin).to.equal(true);

@@ -79,3 +79,3 @@ });

it('fail the validation', () => {
it('fails the validation', () => {
expect(failed).to.be.an('object');

@@ -106,3 +106,3 @@ expect(failed).to.have.key('age');

it('fail the validation', () => {
it('fails the validation', () => {
expect(failedMin).to.be.an('object');

@@ -109,0 +109,0 @@ expect(failedMin).to.have.key('age');

@@ -30,3 +30,3 @@ import {expect} from 'chai';

it('pass the validation', () => {
it('passes the validation', () => {
expect(res).to.equal(true);

@@ -52,3 +52,3 @@ });

it('fail the validation', () => {
it('fails the validation', () => {
expect(failed).to.be.an('object');

@@ -55,0 +55,0 @@ expect(failed).to.have.key('age');

@@ -53,3 +53,3 @@ import {expect} from 'chai';

it('pass the validation', () => {
it('passes the validation', () => {
expect(res).to.equal(true);

@@ -71,3 +71,2 @@ });

failed = error;
console.log('.....failed', failed);
done();

@@ -74,0 +73,0 @@ });

@@ -30,3 +30,3 @@ import {expect} from 'chai';

it('pass the validation', () => {
it('passes the validation', () => {
expect(res).to.equal(true);

@@ -52,3 +52,3 @@ });

it('fail the validation', () => {
it('fails the validation', () => {
expect(failed).to.be.an('object');

@@ -55,0 +55,0 @@ expect(failed).to.have.key('age');

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