@aeriajs/validation 0.0.104 → 0.0.105

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/dist/validate.js CHANGED
@@ -52,14 +52,10 @@ const validateProperty = (propName, what, property, options = {}) => {
52
52
  if (filterOutExtraneous) {
53
53
  return types_1.Result.result(undefined);
54
54
  }
55
- return types_1.Result.result(what);
56
55
  }
57
56
  return types_1.Result.result(what);
58
57
  }
59
- return types_1.Result.error(makePropertyError(types_2.PropertyValidationErrorCode.Extraneous, {
60
- expected: 'undefined',
61
- got: getValueType(what),
62
- }));
58
+ return types_1.Result.error(makePropertyError(types_2.PropertyValidationErrorCode.Extraneous));
63
59
  }
64
60
  if ('getter' in property) {
65
61
  return types_1.Result.result(undefined);
@@ -121,6 +117,16 @@ const validateProperty = (propName, what, property, options = {}) => {
121
117
  got: actualType,
122
118
  }));
123
119
  }
120
+ if (property.minItems) {
121
+ if (what.length < property.minItems) {
122
+ return types_1.Result.error(makePropertyError(types_2.PropertyValidationErrorCode.MoreItemsExpected));
123
+ }
124
+ }
125
+ if (property.maxItems) {
126
+ if (what.length > property.maxItems) {
127
+ return types_1.Result.error(makePropertyError(types_2.PropertyValidationErrorCode.LessItemsExpected));
128
+ }
129
+ }
124
130
  let i = 0;
125
131
  for (const elem of what) {
126
132
  const { error } = (0, exports.validateProperty)(propName, elem, property.items, options);
package/dist/validate.mjs CHANGED
@@ -45,14 +45,10 @@ export const validateProperty = (propName, what, property, options = {}) => {
45
45
  if (filterOutExtraneous) {
46
46
  return Result.result(void 0);
47
47
  }
48
- return Result.result(what);
49
48
  }
50
49
  return Result.result(what);
51
50
  }
52
- return Result.error(makePropertyError(PropertyValidationErrorCode.Extraneous, {
53
- expected: "undefined",
54
- got: getValueType(what)
55
- }));
51
+ return Result.error(makePropertyError(PropertyValidationErrorCode.Extraneous));
56
52
  }
57
53
  if ("getter" in property) {
58
54
  return Result.result(void 0);
@@ -112,6 +108,16 @@ export const validateProperty = (propName, what, property, options = {}) => {
112
108
  got: actualType
113
109
  }));
114
110
  }
111
+ if (property.minItems) {
112
+ if (what.length < property.minItems) {
113
+ return Result.error(makePropertyError(PropertyValidationErrorCode.MoreItemsExpected));
114
+ }
115
+ }
116
+ if (property.maxItems) {
117
+ if (what.length > property.maxItems) {
118
+ return Result.error(makePropertyError(PropertyValidationErrorCode.LessItemsExpected));
119
+ }
120
+ }
115
121
  let i = 0;
116
122
  for (const elem of what) {
117
123
  const { error } = validateProperty(propName, elem, property.items, options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/validation",
3
- "version": "0.0.104",
3
+ "version": "0.0.105",
4
4
  "description": "## Installation",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -26,8 +26,9 @@
26
26
  "@aeriajs/types": "link:../types"
27
27
  },
28
28
  "peerDependencies": {
29
- "@aeriajs/common": "^0.0.101",
30
- "@aeriajs/types": "^0.0.86"
29
+ "@aeriajs/common": "^0.0.102",
30
+ "@aeriajs/types": "^0.0.87",
31
+ "mongodb": "^6.5.0"
31
32
  },
32
33
  "scripts": {
33
34
  "test": "vitest run",