sigo-entities 0.0.113 → 0.0.115

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
@@ -241,8 +241,13 @@ var import_class_validator55 = require("class-validator");
241
241
  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
- if (propertiesToValidate && propertiesToValidate.length === 0) {
245
- throw new Error(`Debes especificar al menos una propiedad a validar`);
244
+ if (propertiesToValidate) {
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
@@ -44,8 +44,13 @@ import { IsArray as IsArray6, IsEmail as IsEmail2, IsNotEmpty as IsNotEmpty53, I
44
44
  import { plainToInstance } from "class-transformer";
45
45
  import { validate } from "class-validator";
46
46
  async function validateAndFormatData(data, dtoClass, propertiesToValidate) {
47
- if (propertiesToValidate && propertiesToValidate.length === 0) {
48
- throw new Error(`Debes especificar al menos una propiedad a validar`);
47
+ if (propertiesToValidate) {
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.115",
4
4
  "description": "Desarrollo de modelos de datos SIGO",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",