ac-sanitizer 3.9.14 → 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,3 +1,13 @@
1
+ <a name="3.9.15"></a>
2
+
3
+ ## [3.9.15](https://github.com/mmpro/ac-sanitizer/compare/v3.9.14..v3.9.15) (2022-04-22 16:53:45)
4
+
5
+
6
+ ### Bug Fix
7
+
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)
1
11
  <a name="3.9.14"></a>
2
12
 
3
13
  ## [3.9.14](https://github.com/mmpro/ac-sanitizer/compare/v3.9.13..v3.9.14) (2022-04-20 11:41:13)
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 } }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "author": "Mark Poepping (https://www.admiralcloud.com)",
5
5
  "license": "MIT",
6
6
  "repository": "admiralcloud/ac-sanitizer",
7
- "version": "3.9.14",
7
+ "version": "3.9.15",
8
8
  "homepage": "https://www.admiralcloud.com",
9
9
  "dependencies": {
10
10
  "ac-countrylist": "^1.0.6",
@@ -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'] },