n4s 4.3.6 → 4.3.8-dev-9c596e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/compose.development.js +10 -14
- package/dist/cjs/compose.production.js +1 -1
- package/dist/cjs/compounds.development.js +17 -33
- package/dist/cjs/compounds.production.js +1 -1
- package/dist/cjs/n4s.development.js +100 -139
- package/dist/cjs/n4s.production.js +1 -1
- package/dist/cjs/schema.development.js +14 -21
- package/dist/cjs/schema.production.js +1 -1
- package/dist/es/compose.development.js +10 -14
- package/dist/es/compose.production.js +1 -1
- package/dist/es/compounds.development.js +17 -33
- package/dist/es/compounds.production.js +1 -1
- package/dist/es/n4s.development.js +120 -159
- package/dist/es/n4s.production.js +1 -1
- package/dist/es/schema.development.js +14 -21
- package/dist/es/schema.production.js +1 -1
- package/dist/umd/compose.development.js +13 -17
- package/dist/umd/compose.production.js +1 -1
- package/dist/umd/compounds.development.js +20 -36
- package/dist/umd/compounds.production.js +1 -1
- package/dist/umd/n4s.development.js +100 -139
- package/dist/umd/n4s.production.js +1 -1
- package/dist/umd/schema.development.js +17 -24
- package/dist/umd/schema.production.js +1 -1
- package/package.json +3 -3
- package/testUtils/TEnforceMock.ts +3 -0
- package/types/compounds.d.ts.map +1 -1
- package/types/schema.d.ts.map +1 -1
- package/tsconfig.json +0 -62
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.compose = factory(global["vest-utils"]
|
|
5
|
-
})(this, (function (
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('n4s'), require('vest-utils')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['n4s', 'vest-utils'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.compose = factory(global.n4s, global["vest-utils"]));
|
|
5
|
+
})(this, (function (n4s, vestUtils) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function ruleReturn(pass, message) {
|
|
8
|
-
|
|
8
|
+
const output = { pass };
|
|
9
9
|
if (message) {
|
|
10
10
|
output.message = message;
|
|
11
11
|
}
|
|
@@ -31,27 +31,23 @@
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/* eslint-disable max-lines-per-function */
|
|
34
|
-
function compose() {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
composites[_i] = arguments[_i];
|
|
38
|
-
}
|
|
39
|
-
return vestUtils.assign(function (value) {
|
|
40
|
-
var res = run(value);
|
|
34
|
+
function compose(...composites) {
|
|
35
|
+
return vestUtils.assign((value) => {
|
|
36
|
+
const res = run(value);
|
|
41
37
|
vestUtils.invariant(res.pass, vestUtils.StringObject(res.message));
|
|
42
38
|
}, {
|
|
43
|
-
run
|
|
44
|
-
test:
|
|
39
|
+
run,
|
|
40
|
+
test: (value) => run(value).pass,
|
|
45
41
|
});
|
|
46
42
|
function run(value) {
|
|
47
|
-
return n4s.ctx.run({ value
|
|
48
|
-
return defaultToPassing(vestUtils.mapFirst(composites,
|
|
43
|
+
return n4s.ctx.run({ value }, () => {
|
|
44
|
+
return defaultToPassing(vestUtils.mapFirst(composites, (composite, breakout) => {
|
|
49
45
|
/* HACK: Just a small white lie. ~~HELP WANTED~~.
|
|
50
46
|
The ideal is that instead of `LazyRuleRunners` We would simply use `Lazy` to begin with.
|
|
51
47
|
The problem is that lazy rules can't really be passed to this function due to some generic hell
|
|
52
48
|
so we're limiting it to a small set of functions.
|
|
53
49
|
*/
|
|
54
|
-
|
|
50
|
+
const res = runLazyRule(composite, value);
|
|
55
51
|
breakout(!res.pass, res);
|
|
56
52
|
}));
|
|
57
53
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("n4s"),require("vest-utils")):"function"==typeof define&&define.amd?define(["n4s","vest-utils"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).compose=t(e.n4s,e["vest-utils"])}(this,(function(e,t){"use strict";function n(e,t){const n={pass:e};return t&&(n.message=t),n}function s(e){return t.defaultTo(e,n(!0))}function u(e,t){try{return e.run(t)}catch(e){return n(!1)}}return function(...n){return t.assign((e=>{const n=r(e);t.invariant(n.pass,t.StringObject(n.message))}),{run:r,test:e=>r(e).pass});function r(r){return e.ctx.run({value:r},(()=>s(t.mapFirst(n,((e,t)=>{const n=u(e,r);t(!n.pass,n)})))))}}}));
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["vest-utils"]
|
|
5
|
-
})(this, (function (
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('n4s'), require('vest-utils')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['n4s', 'vest-utils'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.n4s, global["vest-utils"]));
|
|
5
|
+
})(this, (function (n4s, vestUtils) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function ruleReturn(pass, message) {
|
|
8
|
-
|
|
8
|
+
const output = { pass };
|
|
9
9
|
if (message) {
|
|
10
10
|
output.message = message;
|
|
11
11
|
}
|
|
@@ -33,35 +33,23 @@
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
function allOf(value) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
rules[_i - 1] = arguments[_i];
|
|
40
|
-
}
|
|
41
|
-
return defaultToPassing(vestUtils.mapFirst(rules, function (rule, breakout) {
|
|
42
|
-
var res = runLazyRule(rule, value);
|
|
36
|
+
function allOf(value, ...rules) {
|
|
37
|
+
return defaultToPassing(vestUtils.mapFirst(rules, (rule, breakout) => {
|
|
38
|
+
const res = runLazyRule(rule, value);
|
|
43
39
|
breakout(!res.pass, res);
|
|
44
40
|
}));
|
|
45
41
|
}
|
|
46
42
|
|
|
47
|
-
function anyOf(value) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
rules[_i - 1] = arguments[_i];
|
|
51
|
-
}
|
|
52
|
-
return defaultToFailing(vestUtils.mapFirst(rules, function (rule, breakout) {
|
|
53
|
-
var res = runLazyRule(rule, value);
|
|
43
|
+
function anyOf(value, ...rules) {
|
|
44
|
+
return defaultToFailing(vestUtils.mapFirst(rules, (rule, breakout) => {
|
|
45
|
+
const res = runLazyRule(rule, value);
|
|
54
46
|
breakout(res.pass, res);
|
|
55
47
|
}));
|
|
56
48
|
}
|
|
57
49
|
|
|
58
|
-
function noneOf(value) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
rules[_i - 1] = arguments[_i];
|
|
62
|
-
}
|
|
63
|
-
return defaultToPassing(vestUtils.mapFirst(rules, function (rule, breakout) {
|
|
64
|
-
var res = runLazyRule(rule, value);
|
|
50
|
+
function noneOf(value, ...rules) {
|
|
51
|
+
return defaultToPassing(vestUtils.mapFirst(rules, (rule, breakout) => {
|
|
52
|
+
const res = runLazyRule(rule, value);
|
|
65
53
|
breakout(res.pass, failing());
|
|
66
54
|
}));
|
|
67
55
|
}
|
|
@@ -71,15 +59,11 @@
|
|
|
71
59
|
}
|
|
72
60
|
vestUtils.bindNot(equals);
|
|
73
61
|
|
|
74
|
-
|
|
75
|
-
function oneOf(value) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
var passingCount = 0;
|
|
81
|
-
rules.some(function (rule) {
|
|
82
|
-
var res = runLazyRule(rule, value);
|
|
62
|
+
const REQUIRED_COUNT = 1;
|
|
63
|
+
function oneOf(value, ...rules) {
|
|
64
|
+
let passingCount = 0;
|
|
65
|
+
rules.some(rule => {
|
|
66
|
+
const res = runLazyRule(rule, value);
|
|
83
67
|
if (res.pass) {
|
|
84
68
|
passingCount++;
|
|
85
69
|
}
|
|
@@ -90,6 +74,6 @@
|
|
|
90
74
|
return ruleReturn(equals(passingCount, REQUIRED_COUNT));
|
|
91
75
|
}
|
|
92
76
|
|
|
93
|
-
n4s.enforce.extend({ allOf
|
|
77
|
+
n4s.enforce.extend({ allOf, anyOf, noneOf, oneOf });
|
|
94
78
|
|
|
95
79
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("
|
|
1
|
+
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("n4s"),require("vest-utils")):"function"==typeof define&&define.amd?define(["n4s","vest-utils"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).n4s,n["vest-utils"])}(this,(function(n,t){"use strict";function e(n,t){const e={pass:n};return t&&(e.message=t),e}function r(){return e(!1)}function s(n){return t.defaultTo(n,e(!0))}function u(n,t){try{return n.run(t)}catch(n){return r()}}function i(n,t){return n===t}t.bindNot(i);n.enforce.extend({allOf:function(n,...e){return s(t.mapFirst(e,((t,e)=>{const r=u(t,n);e(!r.pass,r)})))},anyOf:function(n,...e){return s=t.mapFirst(e,((t,e)=>{const r=u(t,n);e(r.pass,r)})),t.defaultTo(s,r());var s},noneOf:function(n,...e){return s(t.mapFirst(e,((t,e)=>{e(u(t,n).pass,r())})))},oneOf:function(n,...r){let s=0;return r.some((e=>{if(u(e,n).pass&&s++,t.greaterThan(s,1))return!1})),e(i(s,1))}})}));
|