@innet/server 2.0.0-beta.1 → 2.0.0-beta.2

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 (110) hide show
  1. package/README.md +22 -0
  2. package/handler/handler.d.ts +1 -7
  3. package/handler/handler.es6.js +1 -4
  4. package/handler/handler.js +0 -3
  5. package/hooks/useHeaders/useHeaders.d.ts +0 -1
  6. package/hooks/useNewSchema/useNewSchema.es6.js +1 -1
  7. package/hooks/useNewSchema/useNewSchema.js +1 -1
  8. package/hooks/useRequest/useRequest.d.ts +0 -1
  9. package/hooks/useResponse/useResponse.d.ts +0 -1
  10. package/hooks/useSchemaType/useSchemaType.es6.js +17 -9
  11. package/hooks/useSchemaType/useSchemaType.js +17 -9
  12. package/hooks/useServer/useServer.d.ts +0 -2
  13. package/index.es6.js +0 -1
  14. package/index.js +0 -1
  15. package/package.json +15 -15
  16. package/plugins/handler/serverFn/serverFn.es6.js +1 -1
  17. package/plugins/handler/serverFn/serverFn.js +1 -1
  18. package/plugins/main/api/api.es6.js +73 -73
  19. package/plugins/main/api/api.js +73 -73
  20. package/plugins/main/endpoint/endpoint.d.ts +5 -0
  21. package/plugins/main/endpoint/endpoint.es6.js +4 -4
  22. package/plugins/main/endpoint/endpoint.js +4 -4
  23. package/plugins/main/host/host.es6.js +3 -1
  24. package/plugins/main/host/host.js +3 -1
  25. package/plugins/main/param/param.es6.js +2 -3
  26. package/plugins/main/param/param.js +2 -3
  27. package/plugins/main/response/response.es6.js +10 -3
  28. package/plugins/main/response/response.js +10 -3
  29. package/plugins/main/server/server.d.ts +0 -1
  30. package/plugins/main/server/server.es6.js +6 -9
  31. package/plugins/main/server/server.js +6 -9
  32. package/plugins/main/variable/variable.es6.js +3 -4
  33. package/plugins/main/variable/variable.js +3 -4
  34. package/plugins/request/cookie/cookie.d.ts +2 -2
  35. package/plugins/request/cookie/cookie.es6.js +1 -2
  36. package/plugins/request/cookie/cookie.js +1 -2
  37. package/plugins/request/error/error.es6.js +1 -2
  38. package/plugins/request/error/error.js +1 -2
  39. package/plugins/request/file/file.es6.js +1 -2
  40. package/plugins/request/file/file.js +1 -2
  41. package/plugins/request/proxy/proxy.d.ts +0 -1
  42. package/plugins/schema/array/array.es6.js +1 -2
  43. package/plugins/schema/array/array.js +1 -2
  44. package/plugins/schema/date/date.es6.js +8 -4
  45. package/plugins/schema/date/date.js +8 -4
  46. package/plugins/schema/integer/integer.es6.js +8 -3
  47. package/plugins/schema/integer/integer.js +8 -3
  48. package/plugins/schema/number/number.es6.js +1 -2
  49. package/plugins/schema/number/number.js +1 -2
  50. package/plugins/schema/object/object.es6.js +1 -2
  51. package/plugins/schema/object/object.js +1 -2
  52. package/plugins/schema/string/string.es6.js +1 -2
  53. package/plugins/schema/string/string.js +1 -2
  54. package/plugins/schema/tuple/tuple.es6.js +1 -2
  55. package/plugins/schema/tuple/tuple.js +1 -2
  56. package/plugins/schema/uuid/uuid.es6.js +5 -3
  57. package/plugins/schema/uuid/uuid.js +5 -3
  58. package/utils/action/Action.d.ts +4 -5
  59. package/utils/action/Action.es6.js +14 -16
  60. package/utils/action/Action.js +13 -15
  61. package/utils/parseBody/parseBody.d.ts +0 -1
  62. package/utils/parseBody/parseBody.es6.js +13 -16
  63. package/utils/parseBody/parseBody.js +13 -16
  64. package/utils/parseFormBody/parseFormBody.d.ts +0 -1
  65. package/utils/parseFormBody/parseFormBody.es6.js +41 -41
  66. package/utils/parseFormBody/parseFormBody.js +41 -41
  67. package/utils/parseSearch/parseSearch.es6.js +4 -1
  68. package/utils/parseSearch/parseSearch.js +4 -1
  69. package/utils/rules/arrayOf/arrayOf.es6.js +1 -1
  70. package/utils/rules/arrayOf/arrayOf.js +1 -1
  71. package/utils/rules/bin/bin.es6.js +4 -1
  72. package/utils/rules/bin/bin.js +4 -1
  73. package/utils/rules/binaryAccept/binaryAccept.es6.js +5 -2
  74. package/utils/rules/binaryAccept/binaryAccept.js +5 -2
  75. package/utils/rules/dateTo/dateTo.es6.js +4 -1
  76. package/utils/rules/dateTo/dateTo.js +4 -1
  77. package/utils/rules/helpers.es6.js +4 -1
  78. package/utils/rules/helpers.js +4 -1
  79. package/utils/rules/int/int.es6.js +17 -4
  80. package/utils/rules/int/int.js +17 -4
  81. package/utils/rules/max/max.es6.js +9 -3
  82. package/utils/rules/max/max.js +9 -3
  83. package/utils/rules/maxBin/maxBin.es6.js +5 -2
  84. package/utils/rules/maxBin/maxBin.js +5 -2
  85. package/utils/rules/maxDate/maxDate.es6.js +5 -1
  86. package/utils/rules/maxDate/maxDate.js +5 -1
  87. package/utils/rules/maxLength/maxLength.es6.js +5 -2
  88. package/utils/rules/maxLength/maxLength.js +5 -2
  89. package/utils/rules/min/min.es6.js +9 -3
  90. package/utils/rules/min/min.js +9 -3
  91. package/utils/rules/minBin/minBin.es6.js +5 -2
  92. package/utils/rules/minBin/minBin.js +5 -2
  93. package/utils/rules/minDate/minDate.es6.js +5 -1
  94. package/utils/rules/minDate/minDate.js +5 -1
  95. package/utils/rules/minLength/minLength.es6.js +5 -2
  96. package/utils/rules/minLength/minLength.js +5 -2
  97. package/utils/rules/num/num.es6.js +4 -1
  98. package/utils/rules/num/num.js +4 -1
  99. package/utils/rules/objectOf/objectOf.es6.js +6 -3
  100. package/utils/rules/objectOf/objectOf.js +6 -3
  101. package/utils/rules/pattern/pattern.es6.js +6 -2
  102. package/utils/rules/pattern/pattern.js +6 -2
  103. package/utils/rules/tupleOf/tupleOf.es6.js +1 -1
  104. package/utils/rules/tupleOf/tupleOf.js +1 -1
  105. package/utils/rules/values/values.es6.js +5 -2
  106. package/utils/rules/values/values.js +5 -2
  107. package/utils/stringifySearch/stringifySearch.es6.js +4 -1
  108. package/utils/stringifySearch/stringifySearch.js +4 -1
  109. package/_virtual/_rollup-plugin-process-env.es6.js +0 -10
  110. package/_virtual/_rollup-plugin-process-env.js +0 -12
@@ -2,57 +2,57 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib = require('tslib');
6
5
  var multiparty = require('multiparty');
7
6
  require('../FileData/index.js');
8
7
  require('../parseSearch/index.js');
9
8
  var Bin = require('../FileData/Bin.js');
10
9
  var parseSearch = require('../parseSearch/parseSearch.js');
11
10
 
12
- function parseFormBody(req) {
13
- return tslib.__awaiter(this, void 0, void 0, function* () {
14
- return yield new Promise((resolve, reject) => {
15
- const form = new multiparty.Form();
16
- form.parse(req, (error, fields, files) => {
17
- if (error) {
18
- reject(error);
19
- return;
20
- }
21
- let query = '';
22
- const queryFiles = [];
23
- for (const key in fields) {
24
- for (const value of fields[key]) {
25
- if (query) {
26
- query += '&';
27
- }
28
- query += `${key}=${value.replaceAll('=', '%26')}`;
11
+ async function parseFormBody(req) {
12
+ return await new Promise((resolve, reject) => {
13
+ const form = new multiparty.Form();
14
+ form.parse(req, (error, fields, files) => {
15
+ if (error) {
16
+ reject(error);
17
+ return;
18
+ }
19
+ let query = '';
20
+ const queryFiles = [];
21
+ for (const key in fields) {
22
+ for (const value of fields[key]) {
23
+ if (query) {
24
+ query += '&';
29
25
  }
26
+ query += `${key}=${value.replaceAll('=', '%26')}`;
30
27
  }
31
- for (const key in files) {
32
- const values = files[key];
33
- for (const value of values) {
34
- if (query) {
35
- query += '&';
36
- }
37
- query += `${key}==${queryFiles.length}`;
38
- const { headers } = value, options = tslib.__rest(value, ["headers"]);
39
- options.type = headers['content-type'];
40
- options.disposition = headers['content-disposition'];
41
- queryFiles.push(new Bin.Bin(options));
28
+ }
29
+ for (const key in files) {
30
+ const values = files[key];
31
+ for (const value of values) {
32
+ if (query) {
33
+ query += '&';
42
34
  }
35
+ query += `${key}==${queryFiles.length}`;
36
+ const { headers, ...options } = value;
37
+ const binOptions = {
38
+ ...options,
39
+ disposition: headers['content-disposition'],
40
+ type: headers['content-type'],
41
+ };
42
+ queryFiles.push(new Bin.Bin(binOptions));
43
43
  }
44
- resolve(parseSearch.parseSearch(query, {
45
- decoder(value, decoder, charset, type) {
46
- if (type === 'key') {
47
- return decoder(value, decoder, charset);
48
- }
49
- if (value.startsWith('=')) {
50
- return queryFiles[Number(value.slice(1))];
51
- }
52
- return value.replaceAll('%26', '=');
53
- },
54
- }));
55
- });
44
+ }
45
+ resolve(parseSearch.parseSearch(query, {
46
+ decoder(value, decoder, charset, type) {
47
+ if (type === 'key') {
48
+ return decoder(value, decoder, charset);
49
+ }
50
+ if (value.startsWith('=')) {
51
+ return queryFiles[Number(value.slice(1))];
52
+ }
53
+ return value.replaceAll('%26', '=');
54
+ },
55
+ }));
56
56
  });
57
57
  });
58
58
  }
@@ -4,7 +4,10 @@ const EMPTY_SEARCH = {};
4
4
  function parseSearch(search, options) {
5
5
  if (!search)
6
6
  return EMPTY_SEARCH;
7
- return qs.parse(search, Object.assign({ ignoreQueryPrefix: true }, options));
7
+ return qs.parse(search, {
8
+ ignoreQueryPrefix: true,
9
+ ...options,
10
+ });
8
11
  }
9
12
 
10
13
  export { EMPTY_SEARCH, parseSearch };
@@ -12,7 +12,10 @@ const EMPTY_SEARCH = {};
12
12
  function parseSearch(search, options) {
13
13
  if (!search)
14
14
  return EMPTY_SEARCH;
15
- return qs__default["default"].parse(search, Object.assign({ ignoreQueryPrefix: true }, options));
15
+ return qs__default["default"].parse(search, {
16
+ ignoreQueryPrefix: true,
17
+ ...options,
18
+ });
16
19
  }
17
20
 
18
21
  exports.EMPTY_SEARCH = EMPTY_SEARCH;
@@ -8,7 +8,7 @@ function arrayOf(formatter) {
8
8
  else if (!Array.isArray(value)) {
9
9
  value = [value];
10
10
  }
11
- return value.map((val, index) => formatter(val, Object.assign(Object.assign({}, data), { key: addKey(index, data) })));
11
+ return value.map((val, index) => formatter(val, { ...data, key: addKey(index, data) }));
12
12
  };
13
13
  }
14
14
 
@@ -12,7 +12,7 @@ function arrayOf(formatter) {
12
12
  else if (!Array.isArray(value)) {
13
13
  value = [value];
14
14
  }
15
- return value.map((val, index) => formatter(val, Object.assign(Object.assign({}, data), { key: helpers.addKey(index, data) })));
15
+ return value.map((val, index) => formatter(val, { ...data, key: helpers.addKey(index, data) }));
16
16
  };
17
17
  }
18
18
 
@@ -4,7 +4,10 @@ import { Bin } from '../../FileData/Bin.es6.js';
4
4
 
5
5
  function bin(value, data) {
6
6
  if (!(value instanceof Bin)) {
7
- throw new RulesError('binary', Object.assign({ value }, data));
7
+ throw new RulesError('binary', {
8
+ value,
9
+ ...data,
10
+ });
8
11
  }
9
12
  return value;
10
13
  }
@@ -8,7 +8,10 @@ var Bin = require('../../FileData/Bin.js');
8
8
 
9
9
  function bin(value, data) {
10
10
  if (!(value instanceof Bin.Bin)) {
11
- throw new helpers.RulesError('binary', Object.assign({ value }, data));
11
+ throw new helpers.RulesError('binary', {
12
+ value,
13
+ ...data,
14
+ });
12
15
  }
13
16
  return value;
14
17
  }
@@ -24,8 +24,11 @@ function binaryAccept(accept) {
24
24
  continue;
25
25
  return value;
26
26
  }
27
- throw new RulesError('binaryAccept', Object.assign({ accept,
28
- value }, data));
27
+ throw new RulesError('binaryAccept', {
28
+ accept,
29
+ value,
30
+ ...data,
31
+ });
29
32
  };
30
33
  }
31
34
 
@@ -28,8 +28,11 @@ function binaryAccept(accept) {
28
28
  continue;
29
29
  return value;
30
30
  }
31
- throw new helpers.RulesError('binaryAccept', Object.assign({ accept,
32
- value }, data));
31
+ throw new helpers.RulesError('binaryAccept', {
32
+ accept,
33
+ value,
34
+ ...data,
35
+ });
33
36
  };
34
37
  }
35
38
 
@@ -3,7 +3,10 @@ import { RulesError } from '../helpers.es6.js';
3
3
  function dateTo(value, data) {
4
4
  const result = new Date(value);
5
5
  if (isNaN(result)) {
6
- throw new RulesError('date', Object.assign({ value }, data));
6
+ throw new RulesError('date', {
7
+ value,
8
+ ...data,
9
+ });
7
10
  }
8
11
  return result;
9
12
  }
@@ -7,7 +7,10 @@ var helpers = require('../helpers.js');
7
7
  function dateTo(value, data) {
8
8
  const result = new Date(value);
9
9
  if (isNaN(result)) {
10
- throw new helpers.RulesError('date', Object.assign({ value }, data));
10
+ throw new helpers.RulesError('date', {
11
+ value,
12
+ ...data,
13
+ });
11
14
  }
12
15
  return result;
13
16
  }
@@ -1,7 +1,10 @@
1
1
  class RulesError extends Error {
2
2
  constructor(error, data) {
3
3
  super(`Validation Error: ${error}`);
4
- this.data = Object.assign({ error }, data);
4
+ this.data = {
5
+ error,
6
+ ...data,
7
+ };
5
8
  }
6
9
  }
7
10
  function addKey(key, data) {
@@ -5,7 +5,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  class RulesError extends Error {
6
6
  constructor(error, data) {
7
7
  super(`Validation Error: ${error}`);
8
- this.data = Object.assign({ error }, data);
8
+ this.data = {
9
+ error,
10
+ ...data,
11
+ };
9
12
  }
10
13
  }
11
14
  function addKey(key, data) {
@@ -20,14 +20,27 @@ function int(format) {
20
20
  }
21
21
  }
22
22
  if (validator(result)) {
23
- throw new RulesError('integer', Object.assign({ format,
24
- value }, data));
23
+ throw new RulesError('integer', {
24
+ format,
25
+ value,
26
+ ...data,
27
+ });
25
28
  }
26
29
  if (result > sizes[format]) {
27
- throw new RulesError('integer', Object.assign({ format, max: sizes[format], value: result }, data));
30
+ throw new RulesError('integer', {
31
+ format,
32
+ max: sizes[format],
33
+ value: result,
34
+ ...data,
35
+ });
28
36
  }
29
37
  if (result < -sizes[format]) {
30
- throw new RulesError('integer', Object.assign({ format, min: -sizes[format], value: result }, data));
38
+ throw new RulesError('integer', {
39
+ format,
40
+ min: -sizes[format],
41
+ value: result,
42
+ ...data,
43
+ });
31
44
  }
32
45
  return result;
33
46
  };
@@ -24,14 +24,27 @@ function int(format) {
24
24
  }
25
25
  }
26
26
  if (validator(result)) {
27
- throw new helpers.RulesError('integer', Object.assign({ format,
28
- value }, data));
27
+ throw new helpers.RulesError('integer', {
28
+ format,
29
+ value,
30
+ ...data,
31
+ });
29
32
  }
30
33
  if (result > sizes[format]) {
31
- throw new helpers.RulesError('integer', Object.assign({ format, max: sizes[format], value: result }, data));
34
+ throw new helpers.RulesError('integer', {
35
+ format,
36
+ max: sizes[format],
37
+ value: result,
38
+ ...data,
39
+ });
32
40
  }
33
41
  if (result < -sizes[format]) {
34
- throw new helpers.RulesError('integer', Object.assign({ format, min: -sizes[format], value: result }, data));
42
+ throw new helpers.RulesError('integer', {
43
+ format,
44
+ min: -sizes[format],
45
+ value: result,
46
+ ...data,
47
+ });
35
48
  }
36
49
  return result;
37
50
  };
@@ -3,11 +3,17 @@ import { RulesError } from '../helpers.es6.js';
3
3
  function max(max) {
4
4
  return (value, data) => {
5
5
  if (!['bigint', 'number'].includes(typeof value)) {
6
- throw new RulesError('number', Object.assign(Object.assign({}, data), { value }));
6
+ throw new RulesError('number', {
7
+ ...data,
8
+ value,
9
+ });
7
10
  }
8
11
  if (value > max) {
9
- throw new RulesError('maximum', Object.assign(Object.assign({}, data), { max,
10
- value }));
12
+ throw new RulesError('maximum', {
13
+ ...data,
14
+ max,
15
+ value,
16
+ });
11
17
  }
12
18
  return value;
13
19
  };
@@ -7,11 +7,17 @@ var helpers = require('../helpers.js');
7
7
  function max(max) {
8
8
  return (value, data) => {
9
9
  if (!['bigint', 'number'].includes(typeof value)) {
10
- throw new helpers.RulesError('number', Object.assign(Object.assign({}, data), { value }));
10
+ throw new helpers.RulesError('number', {
11
+ ...data,
12
+ value,
13
+ });
11
14
  }
12
15
  if (value > max) {
13
- throw new helpers.RulesError('maximum', Object.assign(Object.assign({}, data), { max,
14
- value }));
16
+ throw new helpers.RulesError('maximum', {
17
+ ...data,
18
+ max,
19
+ value,
20
+ });
15
21
  }
16
22
  return value;
17
23
  };
@@ -3,8 +3,11 @@ import { RulesError } from '../helpers.es6.js';
3
3
  function maxBin(max) {
4
4
  return (value, data) => {
5
5
  if (value.size > max) {
6
- throw new RulesError('maxBin', Object.assign({ max,
7
- value }, data));
6
+ throw new RulesError('maxBin', {
7
+ max,
8
+ value,
9
+ ...data,
10
+ });
8
11
  }
9
12
  return value;
10
13
  };
@@ -7,8 +7,11 @@ var helpers = require('../helpers.js');
7
7
  function maxBin(max) {
8
8
  return (value, data) => {
9
9
  if (value.size > max) {
10
- throw new helpers.RulesError('maxBin', Object.assign({ max,
11
- value }, data));
10
+ throw new helpers.RulesError('maxBin', {
11
+ max,
12
+ value,
13
+ ...data,
14
+ });
12
15
  }
13
16
  return value;
14
17
  };
@@ -6,7 +6,11 @@ function maxDate(max) {
6
6
  throw new RulesError('date', data);
7
7
  }
8
8
  if (value > max) {
9
- throw new RulesError('maxDate', Object.assign(Object.assign({}, data), { max: max.toISOString(), value }));
9
+ throw new RulesError('maxDate', {
10
+ ...data,
11
+ max: max.toISOString(),
12
+ value,
13
+ });
10
14
  }
11
15
  return value;
12
16
  };
@@ -10,7 +10,11 @@ function maxDate(max) {
10
10
  throw new helpers.RulesError('date', data);
11
11
  }
12
12
  if (value > max) {
13
- throw new helpers.RulesError('maxDate', Object.assign(Object.assign({}, data), { max: max.toISOString(), value }));
13
+ throw new helpers.RulesError('maxDate', {
14
+ ...data,
15
+ max: max.toISOString(),
16
+ value,
17
+ });
14
18
  }
15
19
  return value;
16
20
  };
@@ -6,8 +6,11 @@ function maxLength(max) {
6
6
  throw new RulesError('string', data);
7
7
  }
8
8
  if (value.length > max) {
9
- throw new RulesError('maxLength', Object.assign(Object.assign({}, data), { max,
10
- value }));
9
+ throw new RulesError('maxLength', {
10
+ ...data,
11
+ max,
12
+ value,
13
+ });
11
14
  }
12
15
  return value;
13
16
  };
@@ -10,8 +10,11 @@ function maxLength(max) {
10
10
  throw new helpers.RulesError('string', data);
11
11
  }
12
12
  if (value.length > max) {
13
- throw new helpers.RulesError('maxLength', Object.assign(Object.assign({}, data), { max,
14
- value }));
13
+ throw new helpers.RulesError('maxLength', {
14
+ ...data,
15
+ max,
16
+ value,
17
+ });
15
18
  }
16
19
  return value;
17
20
  };
@@ -3,11 +3,17 @@ import { RulesError } from '../helpers.es6.js';
3
3
  function min(min) {
4
4
  return (value, data) => {
5
5
  if (!['bigint', 'number'].includes(typeof value)) {
6
- throw new RulesError('number', Object.assign(Object.assign({}, data), { value }));
6
+ throw new RulesError('number', {
7
+ ...data,
8
+ value,
9
+ });
7
10
  }
8
11
  if (value < min) {
9
- throw new RulesError('minimum', Object.assign(Object.assign({}, data), { min,
10
- value }));
12
+ throw new RulesError('minimum', {
13
+ ...data,
14
+ min,
15
+ value,
16
+ });
11
17
  }
12
18
  return value;
13
19
  };
@@ -7,11 +7,17 @@ var helpers = require('../helpers.js');
7
7
  function min(min) {
8
8
  return (value, data) => {
9
9
  if (!['bigint', 'number'].includes(typeof value)) {
10
- throw new helpers.RulesError('number', Object.assign(Object.assign({}, data), { value }));
10
+ throw new helpers.RulesError('number', {
11
+ ...data,
12
+ value,
13
+ });
11
14
  }
12
15
  if (value < min) {
13
- throw new helpers.RulesError('minimum', Object.assign(Object.assign({}, data), { min,
14
- value }));
16
+ throw new helpers.RulesError('minimum', {
17
+ ...data,
18
+ min,
19
+ value,
20
+ });
15
21
  }
16
22
  return value;
17
23
  };
@@ -3,8 +3,11 @@ import { RulesError } from '../helpers.es6.js';
3
3
  function minBin(min) {
4
4
  return (value, data) => {
5
5
  if (value.size < min) {
6
- throw new RulesError('minBin', Object.assign({ min,
7
- value }, data));
6
+ throw new RulesError('minBin', {
7
+ min,
8
+ value,
9
+ ...data,
10
+ });
8
11
  }
9
12
  return value;
10
13
  };
@@ -7,8 +7,11 @@ var helpers = require('../helpers.js');
7
7
  function minBin(min) {
8
8
  return (value, data) => {
9
9
  if (value.size < min) {
10
- throw new helpers.RulesError('minBin', Object.assign({ min,
11
- value }, data));
10
+ throw new helpers.RulesError('minBin', {
11
+ min,
12
+ value,
13
+ ...data,
14
+ });
12
15
  }
13
16
  return value;
14
17
  };
@@ -6,7 +6,11 @@ function minDate(min) {
6
6
  throw new RulesError('date', data);
7
7
  }
8
8
  if (value < min) {
9
- throw new RulesError('minDate', Object.assign(Object.assign({}, data), { min: min.toISOString(), value }));
9
+ throw new RulesError('minDate', {
10
+ ...data,
11
+ min: min.toISOString(),
12
+ value,
13
+ });
10
14
  }
11
15
  return value;
12
16
  };
@@ -10,7 +10,11 @@ function minDate(min) {
10
10
  throw new helpers.RulesError('date', data);
11
11
  }
12
12
  if (value < min) {
13
- throw new helpers.RulesError('minDate', Object.assign(Object.assign({}, data), { min: min.toISOString(), value }));
13
+ throw new helpers.RulesError('minDate', {
14
+ ...data,
15
+ min: min.toISOString(),
16
+ value,
17
+ });
14
18
  }
15
19
  return value;
16
20
  };
@@ -6,8 +6,11 @@ function minLength(min) {
6
6
  throw new RulesError('string', data);
7
7
  }
8
8
  if (value.length < min) {
9
- throw new RulesError('minLength', Object.assign(Object.assign({}, data), { min,
10
- value }));
9
+ throw new RulesError('minLength', {
10
+ ...data,
11
+ min,
12
+ value,
13
+ });
11
14
  }
12
15
  return value;
13
16
  };
@@ -10,8 +10,11 @@ function minLength(min) {
10
10
  throw new helpers.RulesError('string', data);
11
11
  }
12
12
  if (value.length < min) {
13
- throw new helpers.RulesError('minLength', Object.assign(Object.assign({}, data), { min,
14
- value }));
13
+ throw new helpers.RulesError('minLength', {
14
+ ...data,
15
+ min,
16
+ value,
17
+ });
15
18
  }
16
19
  return value;
17
20
  };
@@ -3,7 +3,10 @@ import { RulesError } from '../helpers.es6.js';
3
3
  function num(value, data) {
4
4
  const result = Number(value);
5
5
  if (isNaN(result) || result > Number.MAX_SAFE_INTEGER || result < -Number.MAX_SAFE_INTEGER) {
6
- throw new RulesError('number', Object.assign({ value }, data));
6
+ throw new RulesError('number', {
7
+ value,
8
+ ...data,
9
+ });
7
10
  }
8
11
  return result;
9
12
  }
@@ -7,7 +7,10 @@ var helpers = require('../helpers.js');
7
7
  function num(value, data) {
8
8
  const result = Number(value);
9
9
  if (isNaN(result) || result > Number.MAX_SAFE_INTEGER || result < -Number.MAX_SAFE_INTEGER) {
10
- throw new helpers.RulesError('number', Object.assign({ value }, data));
10
+ throw new helpers.RulesError('number', {
11
+ value,
12
+ ...data,
13
+ });
11
14
  }
12
15
  return result;
13
16
  }
@@ -3,11 +3,14 @@ import { RulesError, addKey } from '../helpers.es6.js';
3
3
  function objectOf(map, rest) {
4
4
  return (value, data) => {
5
5
  if (value === null || typeof value !== 'object') {
6
- throw new RulesError('object', Object.assign({ value }, data));
6
+ throw new RulesError('object', {
7
+ value,
8
+ ...data,
9
+ });
7
10
  }
8
11
  const result = {};
9
12
  for (const key in map) {
10
- const val = map[key](value[key], Object.assign(Object.assign({}, data), { key: addKey(key, data) }));
13
+ const val = map[key](value[key], { ...data, key: addKey(key, data) });
11
14
  if (val !== undefined) {
12
15
  result[key] = val;
13
16
  }
@@ -16,7 +19,7 @@ function objectOf(map, rest) {
16
19
  for (const key in value) {
17
20
  if (key in map)
18
21
  continue;
19
- const val = rest(value[key], Object.assign(Object.assign({}, data), { key: addKey(key, data) }));
22
+ const val = rest(value[key], { ...data, key: addKey(key, data) });
20
23
  if (val !== undefined) {
21
24
  result[key] = val;
22
25
  }