sigo-entities 0.0.113 → 0.0.114

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/index.js CHANGED
@@ -242,7 +242,12 @@ var import_class_transformer2 = require("class-transformer");
242
242
  var import_class_validator2 = require("class-validator");
243
243
  async function validateAndFormatData(data, dtoClass, propertiesToValidate) {
244
244
  if (propertiesToValidate && propertiesToValidate.length === 0) {
245
- throw new Error(`Debes especificar al menos una propiedad a validar`);
245
+ if (propertiesToValidate.length === 0) {
246
+ throw new Error(`Debes especificar al menos una propiedad a validar`);
247
+ }
248
+ data = Object.fromEntries(
249
+ Object.entries(data).filter(([key]) => propertiesToValidate.includes(key))
250
+ );
246
251
  }
247
252
  const instance = (0, import_class_transformer2.plainToInstance)(dtoClass, data, { excludeExtraneousValues: true });
248
253
  const errors = await (0, import_class_validator2.validate)(instance, { skipMissingProperties: !!propertiesToValidate });
package/dist/index.mjs CHANGED
@@ -45,7 +45,12 @@ import { plainToInstance } from "class-transformer";
45
45
  import { validate } from "class-validator";
46
46
  async function validateAndFormatData(data, dtoClass, propertiesToValidate) {
47
47
  if (propertiesToValidate && propertiesToValidate.length === 0) {
48
- throw new Error(`Debes especificar al menos una propiedad a validar`);
48
+ if (propertiesToValidate.length === 0) {
49
+ throw new Error(`Debes especificar al menos una propiedad a validar`);
50
+ }
51
+ data = Object.fromEntries(
52
+ Object.entries(data).filter(([key]) => propertiesToValidate.includes(key))
53
+ );
49
54
  }
50
55
  const instance = plainToInstance(dtoClass, data, { excludeExtraneousValues: true });
51
56
  const errors = await validate(instance, { skipMissingProperties: !!propertiesToValidate });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sigo-entities",
3
- "version": "0.0.113",
3
+ "version": "0.0.114",
4
4
  "description": "Desarrollo de modelos de datos SIGO",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",