@aeriajs/validation 0.0.146 → 0.0.147

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.
@@ -11,7 +11,7 @@ export declare const validateProperty: <TWhat>(what: TWhat, property: Property |
11
11
  export declare const validateRefs: <TWhat>(what: TWhat, property: Property | Description | undefined, options?: ValidateOptions, descriptions?: Record<string, Description>) => Promise<Result.Either<PropertyValidationError | ValidationError, unknown>>;
12
12
  export declare const validateWholeness: (what: Record<string, unknown>, schema: Omit<JsonSchema, "$id">) => {
13
13
  code: ValidationErrorCode.MissingProperties;
14
- errors: {
14
+ details: {
15
15
  [k: string]: {
16
16
  type: "missing";
17
17
  };
package/dist/validate.js CHANGED
@@ -178,7 +178,7 @@ const validateProperty = (what, property, options = {}) => {
178
178
  for (const elem of what) {
179
179
  const { error } = (0, exports.validateProperty)(elem, property.items, options);
180
180
  if (error) {
181
- if ('errors' in error) {
181
+ if ('code' in error) {
182
182
  continue;
183
183
  }
184
184
  error.index = i;
@@ -242,17 +242,17 @@ const validateRefs = async (what, property, options, descriptions) => {
242
242
  }
243
243
  }
244
244
  else if ('properties' in property) {
245
- const errors = {};
245
+ const details = {};
246
246
  for (const propName in what) {
247
247
  const { error } = await (0, exports.validateRefs)(what[propName], property.properties[propName], options, descriptions);
248
248
  if (error) {
249
- errors[propName] = error;
249
+ details[propName] = error;
250
250
  }
251
251
  }
252
- if (Object.keys(errors).length > 0) {
252
+ if (Object.keys(details).length > 0) {
253
253
  return types_1.Result.error((0, exports.makeValidationError)({
254
254
  code: types_1.ValidationErrorCode.InvalidProperties,
255
- errors,
255
+ details,
256
256
  }));
257
257
  }
258
258
  }
@@ -268,7 +268,7 @@ const validateWholeness = (what, schema) => {
268
268
  if (missingProps.length > 0) {
269
269
  return (0, exports.makeValidationError)({
270
270
  code: types_1.ValidationErrorCode.MissingProperties,
271
- errors: Object.fromEntries(missingProps.map((error) => [
271
+ details: Object.fromEntries(missingProps.map((error) => [
272
272
  error,
273
273
  {
274
274
  type: 'missing',
@@ -282,7 +282,7 @@ const validate = (what, schema, options = {}) => {
282
282
  if (what === undefined) {
283
283
  return types_1.Result.error((0, exports.makeValidationError)({
284
284
  code: types_1.ValidationErrorCode.EmptyTarget,
285
- errors: {},
285
+ details: {},
286
286
  }));
287
287
  }
288
288
  if (!('properties' in schema)) {
@@ -299,7 +299,7 @@ const validate = (what, schema, options = {}) => {
299
299
  }
300
300
  return types_1.Result.error(wholenessError);
301
301
  }
302
- const errors = {};
302
+ const details = {};
303
303
  const resultCopy = {};
304
304
  for (const propName in what) {
305
305
  const { error, result: parsed } = (0, exports.validateProperty)(what[propName], schema.properties[propName], {
@@ -310,17 +310,17 @@ const validate = (what, schema, options = {}) => {
310
310
  if (options.throwOnError) {
311
311
  throw new TypeError(types_1.ValidationErrorCode.InvalidProperties);
312
312
  }
313
- errors[propName] = error;
313
+ details[propName] = error;
314
314
  continue;
315
315
  }
316
316
  if (parsed !== undefined) {
317
317
  resultCopy[propName] = parsed;
318
318
  }
319
319
  }
320
- if (Object.keys(errors).length > 0) {
320
+ if (Object.keys(details).length > 0) {
321
321
  return types_1.Result.error((0, exports.makeValidationError)({
322
322
  code: types_1.ValidationErrorCode.InvalidProperties,
323
- errors,
323
+ details,
324
324
  }));
325
325
  }
326
326
  return types_1.Result.result(resultCopy);
package/dist/validate.mjs CHANGED
@@ -167,7 +167,7 @@ export const validateProperty = (what, property, options = {}) => {
167
167
  for (const elem of what) {
168
168
  const { error } = validateProperty(elem, property.items, options);
169
169
  if (error) {
170
- if ("errors" in error) {
170
+ if ("code" in error) {
171
171
  continue;
172
172
  }
173
173
  error.index = i;
@@ -225,17 +225,17 @@ export const validateRefs = async (what, property, options, descriptions) => {
225
225
  }
226
226
  }
227
227
  } else if ("properties" in property) {
228
- const errors = {};
228
+ const details = {};
229
229
  for (const propName in what) {
230
230
  const { error } = await validateRefs(what[propName], property.properties[propName], options, descriptions);
231
231
  if (error) {
232
- errors[propName] = error;
232
+ details[propName] = error;
233
233
  }
234
234
  }
235
- if (Object.keys(errors).length > 0) {
235
+ if (Object.keys(details).length > 0) {
236
236
  return Result.error(makeValidationError({
237
237
  code: ValidationErrorCode.InvalidProperties,
238
- errors
238
+ details
239
239
  }));
240
240
  }
241
241
  }
@@ -248,7 +248,7 @@ export const validateWholeness = (what, schema) => {
248
248
  if (missingProps.length > 0) {
249
249
  return makeValidationError({
250
250
  code: ValidationErrorCode.MissingProperties,
251
- errors: Object.fromEntries(missingProps.map((error) => [
251
+ details: Object.fromEntries(missingProps.map((error) => [
252
252
  error,
253
253
  {
254
254
  type: "missing"
@@ -261,7 +261,7 @@ export const validate = (what, schema, options = {}) => {
261
261
  if (what === void 0) {
262
262
  return Result.error(makeValidationError({
263
263
  code: ValidationErrorCode.EmptyTarget,
264
- errors: {}
264
+ details: {}
265
265
  }));
266
266
  }
267
267
  if (!("properties" in schema)) {
@@ -278,7 +278,7 @@ export const validate = (what, schema, options = {}) => {
278
278
  }
279
279
  return Result.error(wholenessError);
280
280
  }
281
- const errors = {};
281
+ const details = {};
282
282
  const resultCopy = {};
283
283
  for (const propName in what) {
284
284
  const { error, result: parsed } = validateProperty(what[propName], schema.properties[propName], {
@@ -289,17 +289,17 @@ export const validate = (what, schema, options = {}) => {
289
289
  if (options.throwOnError) {
290
290
  throw new TypeError(ValidationErrorCode.InvalidProperties);
291
291
  }
292
- errors[propName] = error;
292
+ details[propName] = error;
293
293
  continue;
294
294
  }
295
295
  if (parsed !== void 0) {
296
296
  resultCopy[propName] = parsed;
297
297
  }
298
298
  }
299
- if (Object.keys(errors).length > 0) {
299
+ if (Object.keys(details).length > 0) {
300
300
  return Result.error(makeValidationError({
301
301
  code: ValidationErrorCode.InvalidProperties,
302
- errors
302
+ details
303
303
  }));
304
304
  }
305
305
  return Result.result(resultCopy);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/validation",
3
- "version": "0.0.146",
3
+ "version": "0.0.147",
4
4
  "description": "## Installation",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -27,9 +27,9 @@
27
27
  "@aeriajs/types": "link:../types"
28
28
  },
29
29
  "peerDependencies": {
30
- "@aeriajs/common": "^0.0.131",
31
- "@aeriajs/entrypoint": "^0.0.134",
32
- "@aeriajs/types": "^0.0.113",
30
+ "@aeriajs/common": "^0.0.132",
31
+ "@aeriajs/entrypoint": "^0.0.135",
32
+ "@aeriajs/types": "^0.0.114",
33
33
  "mongodb": "^6.5.0"
34
34
  },
35
35
  "scripts": {