ac-sanitizer 3.9.13 → 3.9.16

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,3 +1,39 @@
1
+ <a name="3.9.16"></a>
2
+
3
+ ## [3.9.16](https://github.com/mmpro/ac-sanitizer/compare/v3.9.15..v3.9.16) (2022-04-24 14:23:01)
4
+
5
+
6
+ ### Bug Fix
7
+
8
+ * **App:** Allow empty string for type integer | string | MP | [c06c64611a83f324d7736314e299d5fb768ab3a7](https://github.com/mmpro/ac-sanitizer/commit/c06c64611a83f324d7736314e299d5fb768ab3a7)
9
+ Allow empty string for type integer
10
+ string
11
+ Related issues: [/issues#undefined](https://github.com//issues/undefined)
12
+ ### Chores
13
+
14
+ * **App:** Updated packages | MP | [f5cf0cabe083f991f455c47df596cbe27ba12054](https://github.com/mmpro/ac-sanitizer/commit/f5cf0cabe083f991f455c47df596cbe27ba12054)
15
+ Updated packages
16
+ Related issues: [undefined/undefined#master](undefined/browse/master)
17
+ <a name="3.9.15"></a>
18
+
19
+ ## [3.9.15](https://github.com/mmpro/ac-sanitizer/compare/v3.9.14..v3.9.15) (2022-04-22 16:53:45)
20
+
21
+
22
+ ### Bug Fix
23
+
24
+ * **App:** Remove entries from array which are not in enum | MP | [20fb76be489ff990e6777d0884ca32beea59b18e](https://github.com/mmpro/ac-sanitizer/commit/20fb76be489ff990e6777d0884ca32beea59b18e)
25
+ Remove entries from array which are not in enum
26
+ Related issues: [undefined/undefined#master](undefined/browse/master)
27
+ <a name="3.9.14"></a>
28
+
29
+ ## [3.9.14](https://github.com/mmpro/ac-sanitizer/compare/v3.9.13..v3.9.14) (2022-04-20 11:41:13)
30
+
31
+
32
+ ### Bug Fix
33
+
34
+ * **App:** Package updated | MP | [d683df4256efd105f1ced1681a3eaa6a06f0ca10](https://github.com/mmpro/ac-sanitizer/commit/d683df4256efd105f1ced1681a3eaa6a06f0ca10)
35
+ Packages updated
36
+ Related issues: [undefined/undefined#master](undefined/browse/master)
1
37
  <a name="3.9.13"></a>
2
38
 
3
39
  ## [3.9.13](https://github.com/mmpro/ac-sanitizer/compare/v3.9.12..v3.9.13) (2022-04-20 11:35:54)
package/index.js CHANGED
@@ -96,7 +96,7 @@ const sanitizer = function() {
96
96
 
97
97
  /// SPECIAL FIELDS
98
98
  // special field - can be string or integer -> determine type and then use type settings
99
- if (field.type === 'integer | string' && value) {
99
+ if (field.type === 'integer | string') {
100
100
  if (!_.isString(value) && !_.isFinite(parseInt(value))) {
101
101
  error = { message: fieldName + '_neitherStringNorInteger' }
102
102
  return {
@@ -104,7 +104,7 @@ const sanitizer = function() {
104
104
  }
105
105
  }
106
106
  if (_.isString(value)) {
107
- field.type = 'string'
107
+ field.type = 'string'
108
108
  }
109
109
  else if (_.isFinite(parseInt(value))) {
110
110
  field.type = 'integer'
@@ -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 } }
package/package.json CHANGED
@@ -4,11 +4,11 @@
4
4
  "author": "Mark Poepping (https://www.admiralcloud.com)",
5
5
  "license": "MIT",
6
6
  "repository": "admiralcloud/ac-sanitizer",
7
- "version": "3.9.13",
7
+ "version": "3.9.16",
8
8
  "homepage": "https://www.admiralcloud.com",
9
9
  "dependencies": {
10
10
  "ac-countrylist": "^1.0.6",
11
- "ac-file-extensions": "^2.0.3",
11
+ "ac-file-extensions": "^2.0.5",
12
12
  "ac-ip": "^1.3.7",
13
13
  "date-and-time": "^2.3.1",
14
14
  "hashids": "^2.2.10",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "devDependencies": {
19
19
  "ac-semantic-release": "^0.3.0",
20
- "eslint": "^8.13.0",
20
+ "eslint": "^8.14.0",
21
21
  "expect": "^27.5.1",
22
22
  "mocha": "^9.2.2",
23
23
  "nyc": "^15.1.0"
@@ -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'] },
@@ -8,6 +8,7 @@ module.exports = {
8
8
 
9
9
  const baseTests = [
10
10
  { name: 'Valid string', type: 'integer | string', value: 'abc-123', expected: 'abc-123' },
11
+ { name: 'Valid empty string', type: 'integer | string', value: '', expected: '', minLength: 0 },
11
12
  { name: 'Valid integer', type: 'integer | string', value: 123, expected: 123 },
12
13
  { name: 'Invalid - neither string nor integer', type: 'integer | string', value: ['abc'], error: 'stringOrInteger_neitherStringNorInteger' },
13
14
  ]