@reactables/forms 0.7.0-alpha.11 → 0.7.0-alpha.14

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.
@@ -1,3 +1,4 @@
1
1
  import { ValidatorFn } from '../Models/Validators';
2
2
  export declare const required: ValidatorFn;
3
+ export declare const arrayNotEmpty: ValidatorFn;
3
4
  export declare const email: ValidatorFn;
package/dist/index.js CHANGED
@@ -26,17 +26,20 @@ var Controls = /*#__PURE__*/Object.freeze({
26
26
  });
27
27
 
28
28
  var required = function (value) {
29
- if (Array.isArray(value)) {
30
- return { required: !Boolean(value.length) };
31
- }
32
29
  if (typeof value === 'string' || typeof value === 'object') {
33
30
  return { required: !Boolean(value) };
34
31
  }
35
32
  if (typeof value === 'number') {
36
33
  return { required: !(value !== undefined && value !== null) };
37
34
  }
35
+ if (typeof value === 'boolean') {
36
+ return { required: !value };
37
+ }
38
38
  return { required: false };
39
39
  };
40
+ var arrayNotEmpty = function (value) { return ({
41
+ arrayNotEmpty: !Boolean(value.length)
42
+ }); };
40
43
  var email = function (value) {
41
44
  return value && !/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/g.test(value) ? { email: true } : { email: false };
42
45
  };
@@ -44,12 +47,14 @@ var email = function (value) {
44
47
  var Validators = /*#__PURE__*/Object.freeze({
45
48
  __proto__: null,
46
49
  required: required,
50
+ arrayNotEmpty: arrayNotEmpty,
47
51
  email: email
48
52
  });
49
53
 
50
54
  var index = /*#__PURE__*/Object.freeze({
51
55
  __proto__: null,
52
56
  required: required,
57
+ arrayNotEmpty: arrayNotEmpty,
53
58
  email: email
54
59
  });
55
60
 
@@ -340,7 +345,7 @@ var updateDescendants = function (state, _a, providers) {
340
345
  var key = _a[0], control = _a[1];
341
346
  if (isChildRef(control.controlRef, controlRef)) {
342
347
  var childValue = value[control.controlRef.at(-1)];
343
- var validatorErrors = getErrors(control, value, providers);
348
+ var validatorErrors = getErrors(control, childValue, providers);
344
349
  var newControl = __assign(__assign({}, control), { value: childValue, validatorErrors: validatorErrors, dirty: !isEqual__default["default"](childValue, control.pristineValue) });
345
350
  acc = {
346
351
  form: __assign(__assign({}, acc.form), (_b = {}, _b[key] = newControl, _b)),
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "author": "David Lai",
15
15
  "license": "ISC",
16
16
  "dependencies": {
17
- "@reactables/core": "^0.7.0-alpha.11",
17
+ "@reactables/core": "^0.7.0-alpha.14",
18
18
  "lodash.isequal": "^4.5.0"
19
19
  },
20
20
  "peerDependencies": {
@@ -23,5 +23,5 @@
23
23
  "devDependencies": {
24
24
  "lodash.clonedeep": "^4.5.0"
25
25
  },
26
- "version": "0.7.0-alpha.11"
26
+ "version": "0.7.0-alpha.14"
27
27
  }