ac-sanitizer 3.10.2 → 3.10.3

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,18 @@
1
+ <a name="3.10.3"></a>
2
+
3
+ ## [3.10.3](https://github.com/mmpro/ac-sanitizer/compare/v3.10.2..v3.10.3) (2022-05-15 15:04:15)
4
+
5
+
6
+ ### Bug Fix
7
+
8
+ * **App:** Allow array of objects for enum/allowed values | MP | [b8ed58e8ece9e6b11efa25b3f65ebaa77d690dc2](https://github.com/mmpro/ac-sanitizer/commit/b8ed58e8ece9e6b11efa25b3f65ebaa77d690dc2)
9
+ Allow array of objects for enum/allowed values
10
+ Related issues: [/issues#undefined](https://github.com//issues/undefined)
11
+ ### Chores
12
+
13
+ * **App:** Updated packages | MP | [1912835f9d881df59806c19275621d83feeb55ac](https://github.com/mmpro/ac-sanitizer/commit/1912835f9d881df59806c19275621d83feeb55ac)
14
+ Updated packages
15
+ Related issues: [/issues#undefined](https://github.com//issues/undefined)
1
16
  <a name="3.10.2"></a>
2
17
 
3
18
  ## [3.10.2](https://github.com/mmpro/ac-sanitizer/compare/v3.10.1..v3.10.2) (2022-04-28 11:21:08)
package/index.js CHANGED
@@ -456,11 +456,11 @@ const sanitizer = function() {
456
456
 
457
457
  if (!error && allowedValues && value) {
458
458
  if (_.isArray(value)) {
459
- if (_.size(value) && !_.size(_.intersection(value, allowedValues))) {
459
+ if (_.size(value) && !_.size(_.intersectionWith(value, allowedValues, _.isEqual))) {
460
460
  error = { message: fieldName + '_notAnAllowedValue', additionalInfo: { value } }
461
461
  }
462
462
  // remove non-matching entries, but do not fail/return error
463
- value = _.intersection(value, allowedValues)
463
+ value = _.intersectionWith(value, allowedValues, _.isEqual)
464
464
  _.set(paramsToCheck, fieldName, value)
465
465
  }
466
466
  else if (_.indexOf(allowedValues, value) < 0) {
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.10.2",
7
+ "version": "3.10.3",
8
8
  "homepage": "https://www.admiralcloud.com",
9
9
  "dependencies": {
10
10
  "ac-countrylist": "^1.0.6",
@@ -17,9 +17,9 @@
17
17
  },
18
18
  "devDependencies": {
19
19
  "ac-semantic-release": "^0.3.0",
20
- "eslint": "^8.14.0",
20
+ "eslint": "^8.15.0",
21
21
  "expect": "^27.5.1",
22
- "mocha": "^9.2.2",
22
+ "mocha": "^10.0.0",
23
23
  "nyc": "^15.1.0"
24
24
  },
25
25
  "scripts": {
@@ -29,6 +29,8 @@ module.exports = {
29
29
  { name: 'Array with maxSize - fail', type: 'array', value: ['a', 'b'], maxSize: 1, error: 'array_maxSizeBoundary' },
30
30
  { name: 'Array of fileExtensions', type: 'array', valueType: 'fileExtension', value: ['jpg'], expected: ['jpg'] },
31
31
  { name: 'Array of fileExtensions - contains invalid', type: 'array', valueType: 'fileExtension', value: ['jpg', 'textimage'], error: 'array_atLeastOneValueFailed' },
32
+ { name: 'Array of objects - valid', type: 'array', value: [{ 'createdAt': 'asc' }], enum: [{ 'createdAt': 'asc' }], expected: [{ 'createdAt': 'asc' }] },
33
+ { name: 'Array of objects - invalid', type: 'array', value: [{ 'createdAt': 'desc' }], enum: [{ 'createdAt': 'asc' }], error: 'array_notAnAllowedValue' },
32
34
  ]
33
35
 
34
36