ac-sanitizer 3.9.11 → 3.9.15

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/CHANGELOG.md CHANGED
@@ -1,30 +1,57 @@
1
- <a name="3.9.11"></a>
1
+ <a name="3.9.15"></a>
2
2
 
3
- ## [3.9.11](https://github.com/mmpro/ac-sanitizer/compare/v3.9.10..v3.9.11) (2022-01-21 13:16:53)
3
+ ## [3.9.15](https://github.com/mmpro/ac-sanitizer/compare/v3.9.14..v3.9.15) (2022-04-22 16:53:45)
4
4
 
5
5
 
6
6
  ### Bug Fix
7
7
 
8
- * **App:** Update package with correct AVIF mimetype | VD | [19dc7d302f090f9723a9495859644f72a8cee7c1](https://github.com/mmpro/ac-sanitizer/commit/19dc7d302f090f9723a9495859644f72a8cee7c1)
9
- Update package with correct AVIF mimetype
10
- <a name="3.9.10"></a>
8
+ * **App:** Remove entries from array which are not in enum | MP | [20fb76be489ff990e6777d0884ca32beea59b18e](https://github.com/mmpro/ac-sanitizer/commit/20fb76be489ff990e6777d0884ca32beea59b18e)
9
+ Remove entries from array which are not in enum
10
+ Related issues: [undefined/undefined#master](undefined/browse/master)
11
+ <a name="3.9.14"></a>
11
12
 
12
- ## [3.9.10](https://github.com/mmpro/ac-sanitizer/compare/v3.9.9..v3.9.10) (2022-01-20 15:26:47)
13
+ ## [3.9.14](https://github.com/mmpro/ac-sanitizer/compare/v3.9.13..v3.9.14) (2022-04-20 11:41:13)
13
14
 
14
15
 
15
16
  ### Bug Fix
16
17
 
17
- * **App:** Update ac-file-extensions package (avif file extension) | VD | [0d50926001ebc741d0e6bf65f4c2863fad684d93](https://github.com/mmpro/ac-sanitizer/commit/0d50926001ebc741d0e6bf65f4c2863fad684d93)
18
- Update ac-file-extensions package (avif file extension)
19
- <a name="3.9.9"></a>
18
+ * **App:** Package updated | MP | [d683df4256efd105f1ced1681a3eaa6a06f0ca10](https://github.com/mmpro/ac-sanitizer/commit/d683df4256efd105f1ced1681a3eaa6a06f0ca10)
19
+ Packages updated
20
+ Related issues: [undefined/undefined#master](undefined/browse/master)
21
+ <a name="3.9.13"></a>
20
22
 
21
- ## [3.9.9](https://github.com/mmpro/ac-sanitizer/compare/v3.9.8..v3.9.9) (2022-01-20 14:57:41)
23
+ ## [3.9.13](https://github.com/mmpro/ac-sanitizer/compare/v3.9.12..v3.9.13) (2022-04-20 11:35:54)
22
24
 
23
25
 
24
26
  ### Bug Fix
25
27
 
28
+ * **App:** Update package with correct AVIF mimetype | VD | [19dc7d302f090f9723a9495859644f72a8cee7c1](https://github.com/mmpro/ac-sanitizer/commit/19dc7d302f090f9723a9495859644f72a8cee7c1)
29
+ Update package with correct AVIF mimetype
30
+ * **App:** Update ac-file-extensions package (avif file extension) | VD | [0d50926001ebc741d0e6bf65f4c2863fad684d93](https://github.com/mmpro/ac-sanitizer/commit/0d50926001ebc741d0e6bf65f4c2863fad684d93)
31
+ Update ac-file-extensions package (avif file extension)
26
32
  * **App:** Update ac-file-extensions package | VD | [13eeb3dccd0154943a08913f719db9df9739582b](https://github.com/mmpro/ac-sanitizer/commit/13eeb3dccd0154943a08913f719db9df9739582b)
27
33
  Update ac-file-extensions package
34
+ ### Chores
35
+
36
+ * **release:** v3.9.11 [ci skip] | [b2148644e40e42cd3bc19cda40cf549113c1f9df](https://github.com/mmpro/ac-sanitizer/commit/b2148644e40e42cd3bc19cda40cf549113c1f9df)
37
+
38
+ * **release:** v3.9.10 [ci skip] | [266be8280314c2f37e15b3f362b7c590f691f525](https://github.com/mmpro/ac-sanitizer/commit/266be8280314c2f37e15b3f362b7c590f691f525)
39
+
40
+ * **release:** v3.9.9 [ci skip] | [2fc8fbea1e4fcd1b981120cfde032ae6e3a6ad24](https://github.com/mmpro/ac-sanitizer/commit/2fc8fbea1e4fcd1b981120cfde032ae6e3a6ad24)
41
+
42
+ <a name="3.9.12"></a>
43
+
44
+ ## [3.9.12](https://github.com/mmpro/ac-sanitizer/compare/v3.9.11..v3.9.12) (2022-04-20 11:32:20)
45
+
46
+ ### Bug Fix
47
+
48
+ * **App:** Minor fix to create random arrays with integers | MP | [f0858a9ec21104c4c7c7480b37ccb4bd62d3552a](https://github.com/mmpro/ac-sanitizer/commit/f0858a9ec21104c4c7c7480b37ccb4bd62d3552a)
49
+ Allow creation of random array with integers
50
+ ### Chores
51
+
52
+ * **App:** Updated packages | MP | [9b1132064b0a6082348f276edfe3e397c0f5203f](https://github.com/mmpro/ac-sanitizer/commit/9b1132064b0a6082348f276edfe3e397c0f5203f)
53
+ Updated packages
54
+ Related issues: [/issues#undefined](https://github.com//issues/undefined)
28
55
  <a name="3.9.8"></a>
29
56
 
30
57
  ## [3.9.8](https://github.com/mmpro/ac-sanitizer/compare/v3.9.7..v3.9.8) (2021-11-27 13:26:51)
package/index.js CHANGED
@@ -423,6 +423,9 @@ const sanitizer = function() {
423
423
  if (_.size(value) && !_.size(_.intersection(value, allowedValues))) {
424
424
  error = { message: fieldName + '_notAnAllowedValue', additionalInfo: { value } }
425
425
  }
426
+ // remove non-matching entries, but do not fail/return error
427
+ value = _.intersection(value, allowedValues)
428
+ _.set(paramsToCheck, fieldName, value)
426
429
  }
427
430
  else if (_.indexOf(allowedValues, value) < 0) {
428
431
  error = { message: fieldName + '_notAnAllowedValue', additionalInfo: { value } }
@@ -464,6 +467,7 @@ const sanitizer = function() {
464
467
  */
465
468
  const randomValue = (params) => {
466
469
  const type = _.get(params, 'type')
470
+ const valueType = _.get(params, 'valueType') // arrays only
467
471
  const size = _.get(params, 'size', 1) // for arrays
468
472
 
469
473
  switch (type) {
@@ -486,7 +490,12 @@ const sanitizer = function() {
486
490
  case 'array': {
487
491
  let arr = []
488
492
  for (let i=0; i<size; i+=1) {
489
- arr.push(Math.random().toString(36))
493
+ if (valueType === 'integer') {
494
+ arr.push(_.random(100))
495
+ }
496
+ else {
497
+ arr.push(Math.random().toString(36))
498
+ }
490
499
  }
491
500
  return arr
492
501
  }
package/package.json CHANGED
@@ -4,22 +4,22 @@
4
4
  "author": "Mark Poepping (https://www.admiralcloud.com)",
5
5
  "license": "MIT",
6
6
  "repository": "admiralcloud/ac-sanitizer",
7
- "version": "3.9.11",
7
+ "version": "3.9.15",
8
8
  "homepage": "https://www.admiralcloud.com",
9
9
  "dependencies": {
10
10
  "ac-countrylist": "^1.0.6",
11
- "ac-file-extensions": "^2.0.3",
12
- "ac-ip": "^1.3.6",
13
- "date-and-time": "^2.0.1",
11
+ "ac-file-extensions": "^2.0.5",
12
+ "ac-ip": "^1.3.7",
13
+ "date-and-time": "^2.3.1",
14
14
  "hashids": "^2.2.10",
15
15
  "lodash": "^4.17.21",
16
16
  "validator": "^13.7.0"
17
17
  },
18
18
  "devDependencies": {
19
- "ac-semantic-release": "^0.2.7",
20
- "eslint": "^8.3.0",
21
- "expect": "^27.3.1",
22
- "mocha": "^9.1.3",
19
+ "ac-semantic-release": "^0.3.0",
20
+ "eslint": "^8.13.0",
21
+ "expect": "^27.5.1",
22
+ "mocha": "^9.2.2",
23
23
  "nyc": "^15.1.0"
24
24
  },
25
25
  "scripts": {
@@ -12,6 +12,7 @@ module.exports = {
12
12
  { name: 'Invalid array', type: 'array', value: 'a', error: 'array_notAnArray' },
13
13
  { name: 'Array with enum match', type: 'array', value: ['video'], enum: ['audio', 'video'], expected: ['video'] },
14
14
  { name: 'Array without enum match', type: 'array', value: ['cookie'], enum: ['audio', 'video'], error: 'array_notAnAllowedValue' },
15
+ { name: 'Array with one non-matching - should filter out that value', type: 'array', value: ['video', 'cookie'], enum: ['audio', 'video'], expected: ['video'] },
15
16
  { name: 'Array with enum with placeholder countrylist', type: 'array', value: ['Laos'], enum: 'countrylist', expected: ['Laos'] },
16
17
  { name: 'Array with enum with placeholder countrylist - fail', type: 'array', value: ['Paris'], enum: 'countrylist', error: 'array_notAnAllowedValue' },
17
18
  { name: 'Array with enum with placeholder iso-639-2', type: 'array', value: ['deu'], enum: 'iso-639-2', expected: ['deu'] },