vest 4.0.0-dev-cc5cf5 → 4.0.0-dev-31f012

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +52 -44
  2. package/README.md +7 -1
  3. package/dist/cjs/classnames.development.js +3 -3
  4. package/dist/cjs/classnames.production.js +1 -1
  5. package/dist/cjs/promisify.development.js +1 -1
  6. package/dist/cjs/promisify.production.js +1 -1
  7. package/dist/cjs/vest.development.js +394 -180
  8. package/dist/cjs/vest.production.js +1 -1
  9. package/dist/es/classnames.development.js +3 -3
  10. package/dist/es/classnames.production.js +1 -1
  11. package/dist/es/promisify.development.js +1 -1
  12. package/dist/es/promisify.production.js +1 -1
  13. package/dist/es/vest.development.js +394 -180
  14. package/dist/es/vest.production.js +1 -1
  15. package/dist/umd/classnames.development.js +3 -3
  16. package/dist/umd/classnames.production.js +1 -1
  17. package/dist/umd/promisify.development.js +1 -1
  18. package/dist/umd/promisify.production.js +1 -1
  19. package/dist/umd/vest.development.js +394 -180
  20. package/dist/umd/vest.production.js +1 -1
  21. package/package.json +1 -1
  22. package/testUtils/testObjects.ts +11 -2
  23. package/types/classnames.d.ts +2 -2
  24. package/types/vest.d.ts +10 -3
  25. package/docs/.nojekyll +0 -0
  26. package/docs/README.md +0 -107
  27. package/docs/_assets/favicon.ico +0 -0
  28. package/docs/_assets/vest-logo.png +0 -0
  29. package/docs/_sidebar.md +0 -14
  30. package/docs/cross_field_validations.md +0 -34
  31. package/docs/enforce.md +0 -11
  32. package/docs/exclusion.md +0 -129
  33. package/docs/getting_started.md +0 -72
  34. package/docs/group.md +0 -142
  35. package/docs/index.html +0 -41
  36. package/docs/migration.md +0 -202
  37. package/docs/n4s/rules.md +0 -1282
  38. package/docs/node.md +0 -36
  39. package/docs/optional.md +0 -103
  40. package/docs/result.md +0 -249
  41. package/docs/state.md +0 -102
  42. package/docs/test.md +0 -172
  43. package/docs/utilities.md +0 -109
  44. package/docs/warn.md +0 -82
package/CHANGELOG.md CHANGED
@@ -4,67 +4,75 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## 4.0.0 - 2021-10-14
7
+ ## 4.0.0 - 2021-10-31
8
8
  ### Changed or removed
9
- - 7591116 major(context): used named export in context (ealush)
10
- - e8686a0 major(vest, enforce): setup next major version (ealush)
11
- - 6224c32 breaking(vest, enforce): prepare next major (ealush)
9
+ - f5ba507 major(context): used named export in context (ealush)
10
+ - eaed68f breaking(vest, enforce): prepare next major (ealush)
12
11
 
13
12
  ### Added
14
- - bc9c651 feat(vest): support custom optional logic (ealush)
15
- - 6036a45 feat(vest): Add a parser export (ealush)
16
- - 0930c1c feat(vest): isValid with field name (ealush)
17
- - cca7b49 feat(vest): handle execution order state refill with memoized tests (ealush)
18
- - ea0f58a feat(vest): Make the state rely on execution order. Add skipWhen. (undefined)
19
- - fff39e1 added(n4s): partial rule modifier (undefined)
20
- - a2632cd feat(n4s): context propagation within enforce (undefined)
13
+ - e0f0f91 feat(vest): support custom optional logic (ealush)
14
+ - d4fecee feat(vest): Add a parser export (ealush)
15
+ - e72498d feat(vest): isValid with field name (ealush)
16
+ - f60d952 feat(vest): handle execution order state refill with memoized tests (ealush)
17
+ - a2b60c4 feat(vest): Make the state rely on execution order. Make skipWhen set skipped context. (undefined)
18
+ - ae5eb02 added(n4s): partial rule modifier (undefined)
19
+ - 990c68f feat(n4s): context propagation within enforce (undefined)
21
20
 
22
21
  ### Fixed and improved
23
- - 894efe1 patch(vest): Throw error when tests are called in the wrong order (ealush)
24
- - 4f6bdaf vx: add types to exports (ealush)
25
- - 9f17f4a organize vest state hooks (ealush)
26
- - fb72235 patch(vest): infer omitted optional fields (ealush)
27
- - 1a5a309 vx: add dev bundle to exports (ealush)
28
- - 4054a02 fix(vest): prevent changing test status once it was finalized (ealush)
29
- - 2d1d39e patch(vest): add cache invalidation for canceled tests (ealush)
30
- - 33dd851 types(vest): add safeguard around shouldUseErrorAsMessage (ealush)
31
- - ae31d35 patch(vest): some cleanups (ealush)
32
- - 8507ce7 patch(vest): remove duplicate code handling perv test registration (ealush)
33
- - 3fbf162 vx: use context directly from published package (ealush)
34
- - 9b35362 patch: run done callbacks via event (ealush)
35
- - 04c8385 patch(vest): removed state subscription (ealush)
22
+ - 31f0123 patch(vest): move creation functions to event bus (ealush)
23
+ - d23641c patch: Some cleanups (ealush)
24
+ - 7acb76f fix(vest): prevent pending tests from being marked as skipped (ealush)
25
+ - 8851ff5 patch(vest): Add isolate module for containing re-orders (ealush)
26
+ - 0593c0f patch(vest): refresh tests after cancel (ealush)
27
+ - e915b53 patch: add cursor util (ealush)
28
+ - f54ae8b patch(vest): move cursor into context (ealush)
29
+ - fc7627e patch(vest): automatically purge not-found test results (ealush)
30
+ - d68d990 vx: correctly pass cli options to build script (ealush)
31
+ - 7c47b9a patch(vest): Throw error when tests are called in the wrong order (ealush)
32
+ - 01be84e vx: add types to exports (ealush)
33
+ - 7201170 organize vest state hooks (ealush)
34
+ - e39bfd8 patch(vest): infer omitted optional fields (ealush)
35
+ - 93014e3 vx: add dev bundle to exports (ealush)
36
+ - 91df42e fix(vest): prevent changing test status once it was finalized (ealush)
37
+ - 797df3e patch(vest): add cache invalidation for canceled tests (ealush)
38
+ - 14ba6d9 types(vest): add safeguard around shouldUseErrorAsMessage (ealush)
39
+ - 477ca00 patch(vest): some cleanups (ealush)
40
+ - 58d5ed3 patch(vest): remove duplicate code handling perv test registration (ealush)
41
+ - 6a98443 vx: use context directly from published package (ealush)
42
+ - a79e479 patch: run done callbacks via event (ealush)
43
+ - 01d32b7 patch(vest): removed state subscription (ealush)
36
44
  - package.json
37
45
  - packages/anyone/package.json
38
46
  - packages/anyone/package.json
39
47
  - packages/vast/types/vast.d.ts
40
- - 0d204db patch(vest): remove pending and lagging state (ealush)
41
- - 5943a5a patch(vest): convert boolean flags to a single status key (ealush)
42
- - 232f174 patch: simplify fieldname comparison (ealush)
43
- - 7b8335e patch(vest): add useAllIncomplete hook (ealush)
44
- - 25ca816 patch(vest): invalid accounts for warning tests as well (ealush)
45
- - 7053605 patch(vest): isValid counts all required tests per field (ealush)
46
- - b9c1ec5 chore: cleanups (ealush)
48
+ - b10b98b patch(vest): remove pending and lagging state (ealush)
49
+ - dfd2cc3 patch(vest): convert boolean flags to a single status key (ealush)
50
+ - 1c9da6c patch: simplify fieldname comparison (ealush)
51
+ - 43c75a4 patch(vest): add useAllIncomplete hook (ealush)
52
+ - 2dfdc97 patch(vest): invalid accounts for warning tests as well (ealush)
53
+ - 4033cca patch(vest): isValid counts all required tests per field (ealush)
54
+ - 02b28a6 chore: cleanups (ealush)
47
55
  - .eslintrc.js
48
- - a730c66 add(n4s): enforce.condition (ealush)
56
+ - afa16e9 add(n4s): enforce.condition (ealush)
49
57
  - package.json
50
58
  - packages/anyone/package.json
51
- - 0405d3f chore: cleanup residue (undefined)
52
- - ad5aedb chore: remove duplicate types (undefined)
59
+ - d452e26 chore: cleanup residue (undefined)
60
+ - 5982183 chore: remove duplicate types (undefined)
53
61
  - packages/anyone/package.json
54
- - 7b112a7 patch: add nodejs exports (undefined)
55
- - 325d91a patch: remove unused exports (undefined)
62
+ - 52ac8e0 patch: add nodejs exports (undefined)
63
+ - f9c4b3e patch: remove unused exports (undefined)
56
64
  - packages/anyone/package.json
57
- - 55c8116 chore: reduce complexity, remove all lint errors (undefined)
65
+ - db0253b chore: reduce complexity, remove all lint errors (undefined)
58
66
  - packages/anyone/.npmignore
59
67
  - .github/PULL_REQUEST_TEMPLATE.md
60
- - 25a2309 chore: cleanup unused code (ealush)
61
- - 80381c1 lint: handling lint of all packages (ealush)
68
+ - be9c776 chore: cleanup unused code (ealush)
69
+ - c5eb2de lint: handling lint of all packages (ealush)
62
70
  - .gitignore
63
- - f0f3eb1 patch(n4s): add ruleReturn default values (ealush)
64
- - f267191 fix(n4s): make enforce compound runners fall back to correct response (ealush)
65
- - ed895d9 fix(n4s): make enforce chaining work (ealush)
66
- - 2d5aef8 chore: some lint fixes (ealush)
67
- - bc079f0 add cli options support (ealush)
71
+ - d388fdc patch(n4s): add ruleReturn default values (ealush)
72
+ - be91b7e fix(n4s): make enforce compound runners fall back to correct response (ealush)
73
+ - 7e8f25c fix(n4s): make enforce chaining work (ealush)
74
+ - e60ce3b chore: some lint fixes (ealush)
75
+ - fc8e2d8 add cli options support (ealush)
68
76
 
69
77
  ## 3.2.7 - 2021-07-17
70
78
 
package/README.md CHANGED
@@ -62,7 +62,7 @@ Vest tries to remediate this by separating validation logic from feature logic s
62
62
  ## Example code ([Run in sandbox](https://codesandbox.io/s/vest-react-tutorial-finished-ztt8t?file=/src/validate.js))
63
63
 
64
64
  ```js
65
- import { create, only, test, enforce, warn } from 'vest';
65
+ import { create, only, test, enforce, warn, skipWhen } from 'vest';
66
66
 
67
67
  export default create((data = {}, currentField) => {
68
68
  only(currentField);
@@ -88,6 +88,12 @@ export default create((data = {}, currentField) => {
88
88
  enforce(data.password).matches(/[0-9]/);
89
89
  });
90
90
 
91
+ skipWhen(!data.password, () => {
92
+ test('confirm_password', 'Passwords do not match', () => {
93
+ enforce(data.confirm_password).equals(data.password);
94
+ });
95
+ });
96
+
91
97
  test('email', 'Email Address is not valid', () => {
92
98
  enforce(data.email).isEmail();
93
99
  });
@@ -56,10 +56,10 @@ function parse(res) {
56
56
  /**
57
57
  * Creates a function that returns class names that match the validation result
58
58
  */
59
- function classNames(res, classes) {
59
+ function classnames(res, classes) {
60
60
  if (classes === void 0) { classes = {}; }
61
61
  if (!res || !isFunction(res.hasErrors)) {
62
- throwError("[vest/classNames]: Expected first argument to be Vest's result object.");
62
+ throwError("classnames: Expected first argument to be Vest's result object.");
63
63
  }
64
64
  var selectors = parse(res);
65
65
  return function (key) {
@@ -74,4 +74,4 @@ function classNames(res, classes) {
74
74
  };
75
75
  }
76
76
 
77
- module.exports = classNames;
77
+ module.exports = classnames;
@@ -1 +1 @@
1
- "use strict";function t(t){return"function"==typeof t}function r(r,n){var e;return null!==(e=function(r){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return t(r)?r.apply(void 0,n):r}(r))&&void 0!==e?e:n}function n(t){var r=Number(t);return!(isNaN(parseFloat(String(t)))||isNaN(Number(t))||!isFinite(r))}function e(t,r){return n(t)&&n(r)&&Number(t)>Number(r)}function u(t,r){return Object.prototype.hasOwnProperty.call(t,r)}module.exports=function(n,o){void 0===o&&(o={}),n&&t(n.hasErrors)||function(t,n){throw Error(r(n,t))}("[vest/classNames]: Expected first argument to be Vest's result object.");var s=function(t){var r={},n={invalid:t.hasErrors,tested:function(o){return o?u(r,o)?r[o]:(r[o]=u(t.tests,o)&&e(t.tests[o].testCount,0),n.tested(o)):e(t.testCount,0)},untested:function(r){return 0===t.testCount||!n.tested(r)},valid:t.isValid,warning:t.hasWarnings};return n}(n);return function(r){var n,e=[];for(n in o){var u=n;t(s[u])&&s[u](r)&&e.push(o[u])}return e.join(" ")}};
1
+ "use strict";function t(t){return"function"==typeof t}function r(r,n){var e;return null!==(e=function(r){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return t(r)?r.apply(void 0,n):r}(r))&&void 0!==e?e:n}function n(t){var r=Number(t);return!(isNaN(parseFloat(String(t)))||isNaN(Number(t))||!isFinite(r))}function e(t,r){return n(t)&&n(r)&&Number(t)>Number(r)}function u(t,r){return Object.prototype.hasOwnProperty.call(t,r)}module.exports=function(n,o){void 0===o&&(o={}),n&&t(n.hasErrors)||function(t,n){throw Error(r(n,t))}("classnames: Expected first argument to be Vest's result object.");var s=function(t){var r={},n={invalid:t.hasErrors,tested:function(o){return o?u(r,o)?r[o]:(r[o]=u(t.tests,o)&&e(t.tests[o].testCount,0),n.tested(o)):e(t.testCount,0)},untested:function(r){return 0===t.testCount||!n.tested(r)},valid:t.isValid,warning:t.hasWarnings};return n}(n);return function(r){var n,e=[];for(n in o){var u=n;t(s[u])&&s[u](r)&&e.push(o[u])}return e.join(" ")}};
@@ -18,7 +18,7 @@ var promisify = function (validatorFn) {
18
18
  args[_i] = arguments[_i];
19
19
  }
20
20
  if (!isFunction(validatorFn)) {
21
- throwError('[vest/promisify]: Expected validatorFn to be a function.');
21
+ throwError('promisify: Expected validatorFn to be a function.');
22
22
  }
23
23
  return new Promise(function (resolve) { return validatorFn.apply(void 0, args).done(resolve); });
24
24
  };
@@ -1 +1 @@
1
- "use strict";function n(n){return"function"==typeof n}function r(r,t){var o;return null!==(o=function(r){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];return n(r)?r.apply(void 0,t):r}(r))&&void 0!==o?o:t}function t(n,t){throw Error(r(t,n))}module.exports=function(r){return function(){for(var o=[],e=0;e<arguments.length;e++)o[e]=arguments[e];return n(r)||t("[vest/promisify]: Expected validatorFn to be a function."),new Promise((function(n){return r.apply(void 0,o).done(n)}))}};
1
+ "use strict";function n(n){return"function"==typeof n}function r(r,t){var o;return null!==(o=function(r){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];return n(r)?r.apply(void 0,t):r}(r))&&void 0!==o?o:t}function t(n,t){throw Error(r(t,n))}module.exports=function(r){return function(){for(var o=[],e=0;e<arguments.length;e++)o[e]=arguments[e];return n(r)||t("promisify: Expected validatorFn to be a function."),new Promise((function(n){return r.apply(void 0,o).done(n)}))}};