@alanszp/validations 17.0.0 → 18.0.0

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.
@@ -0,0 +1,2 @@
1
+ import { ValidationOptions } from "class-validator";
2
+ export declare function CannotUseWith<T extends object>(propertyName: string, propertyValues?: string[], validationOptions?: ValidationOptions): (object: T, ownPropertyName: string) => void;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CannotUseWith = void 0;
4
+ const lodash_1 = require("lodash");
5
+ const class_validator_1 = require("class-validator");
6
+ function CannotUseWith(propertyName, propertyValues, validationOptions) {
7
+ return function decorator(object, ownPropertyName) {
8
+ (0, class_validator_1.registerDecorator)({
9
+ name: "CannotUseWith",
10
+ target: object.constructor,
11
+ propertyName: ownPropertyName,
12
+ constraints: [],
13
+ options: validationOptions,
14
+ validator: {
15
+ validate(_value, args) {
16
+ const result = propertyValues
17
+ ? propertyValues.every((ppValue) => (0, lodash_1.get)(args.object, propertyName) !== ppValue)
18
+ : (0, lodash_1.get)(args.object, propertyName) !== undefined;
19
+ return result;
20
+ },
21
+ defaultMessage() {
22
+ let message = `Cannot be used with field ${propertyName}`;
23
+ if (propertyValues) {
24
+ message += ` (\`${propertyValues === null || propertyValues === void 0 ? void 0 : propertyValues.join("` , `")}\`)`;
25
+ }
26
+ return `${message}.`;
27
+ },
28
+ },
29
+ });
30
+ };
31
+ }
32
+ exports.CannotUseWith = CannotUseWith;
33
+ //# sourceMappingURL=CannotUseWith.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CannotUseWith.js","sourceRoot":"","sources":["../../src/common-validators/CannotUseWith.ts"],"names":[],"mappings":";;;AAAA,mCAA6B;AAC7B,qDAA4F;AAE5F,SAAgB,aAAa,CAC3B,YAAoB,EACpB,cAAyB,EACzB,iBAAqC;IAErC,OAAO,SAAS,SAAS,CAAC,MAAS,EAAE,eAAuB;QAC1D,IAAA,mCAAiB,EAAC;YAChB,IAAI,EAAE,eAAe;YACrB,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,eAAe;YAC7B,WAAW,EAAE,EAAE;YACf,OAAO,EAAE,iBAAiB;YAC1B,SAAS,EAAE;gBACT,QAAQ,CAAC,MAAe,EAAE,IAAyB;oBACjD,MAAM,MAAM,GAAG,cAAc;wBAC3B,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAA,YAAG,EAAC,IAAI,CAAC,MAAW,EAAE,YAAY,CAAC,KAAK,OAAO,CAAC;wBACpF,CAAC,CAAC,IAAA,YAAG,EAAC,IAAI,CAAC,MAAW,EAAE,YAAY,CAAC,KAAK,SAAS,CAAC;oBAEtD,OAAO,MAAM,CAAC;gBAChB,CAAC;gBACD,cAAc;oBACZ,IAAI,OAAO,GAAG,6BAA6B,YAAY,EAAE,CAAC;oBAC1D,IAAI,cAAc,EAAE;wBAClB,OAAO,IAAI,OAAO,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;qBACtD;oBAED,OAAO,GAAG,OAAO,GAAG,CAAC;gBACvB,CAAC;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AA/BD,sCA+BC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alanszp/validations",
3
- "version": "17.0.0",
3
+ "version": "18.0.0",
4
4
  "description": "Alan's validation utils.",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -26,5 +26,5 @@
26
26
  "@alanszp/errors": ">=12.0.0",
27
27
  "class-validator": "^0.14.0"
28
28
  },
29
- "gitHead": "db3463706e4b0b7fc97aa74e95cc7d6572c5d74b"
29
+ "gitHead": "f32d7a2aff31ce70bdedfe93732e839d5bc03721"
30
30
  }