@cryptexlabs/codex-nodejs-common 0.10.12 → 0.10.14

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/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cryptexlabs/codex-nodejs-common",
3
- "version": "0.10.12",
3
+ "version": "0.10.14",
4
4
  "description": "Common code for Codex framework",
5
5
  "main": "lib/src/index.js",
6
6
  "repository": "git@gitlab.com:cryptexlabs/public/codex-nodejs-common.git",
@@ -0,0 +1,6 @@
1
+ import { ArgumentMetadata, PipeTransform } from "@nestjs/common";
2
+ export declare class FloatValidationPipe implements PipeTransform {
3
+ private _schema;
4
+ constructor();
5
+ transform(value: any, metadata: ArgumentMetadata): any;
6
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.FloatValidationPipe = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const Joi = require("joi");
15
+ let FloatValidationPipe = class FloatValidationPipe {
16
+ constructor() {
17
+ this._schema = Joi.number();
18
+ }
19
+ transform(value, metadata) {
20
+ if (parseFloat(value).toString() !== value.toString()) {
21
+ throw new common_1.BadRequestException(`${value} must be a float`);
22
+ }
23
+ return value;
24
+ }
25
+ };
26
+ exports.FloatValidationPipe = FloatValidationPipe;
27
+ exports.FloatValidationPipe = FloatValidationPipe = __decorate([
28
+ (0, common_1.Injectable)(),
29
+ __metadata("design:paramtypes", [])
30
+ ], FloatValidationPipe);
31
+ //# sourceMappingURL=float.validation.pipe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"float.validation.pipe.js","sourceRoot":"","sources":["../../../src/pipe/float.validation.pipe.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAKwB;AACxB,2BAA2B;AAGpB,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAE9B;QACE,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;IAC9B,CAAC;IAEM,SAAS,CAAC,KAAU,EAAE,QAA0B;QACrD,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;YACtD,MAAM,IAAI,4BAAmB,CAAC,GAAG,KAAK,kBAAkB,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AAZY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;;GACA,mBAAmB,CAY/B"}
@@ -5,3 +5,5 @@ export * from "./not-empty.pipe";
5
5
  export * from "./joi-http-validation.pipe";
6
6
  export * from "./uuidv4.array.validation.pipe";
7
7
  export * from "./uuidv4.validation.pipe";
8
+ export * from "./integer.validation.pipe";
9
+ export * from "./float.validation.pipe";
@@ -21,4 +21,6 @@ __exportStar(require("./not-empty.pipe"), exports);
21
21
  __exportStar(require("./joi-http-validation.pipe"), exports);
22
22
  __exportStar(require("./uuidv4.array.validation.pipe"), exports);
23
23
  __exportStar(require("./uuidv4.validation.pipe"), exports);
24
+ __exportStar(require("./integer.validation.pipe"), exports);
25
+ __exportStar(require("./float.validation.pipe"), exports);
24
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pipe/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,6CAA2B;AAC3B,uDAAqC;AACrC,mDAAiC;AACjC,6DAA2C;AAC3C,iEAA+C;AAC/C,2DAAyC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pipe/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,6CAA2B;AAC3B,uDAAqC;AACrC,mDAAiC;AACjC,6DAA2C;AAC3C,iEAA+C;AAC/C,2DAAyC;AACzC,4DAA0C;AAC1C,0DAAwC"}
@@ -0,0 +1,4 @@
1
+ import { ArgumentMetadata, PipeTransform } from "@nestjs/common";
2
+ export declare class IntegerValidationPipe implements PipeTransform {
3
+ transform(value: any, metadata: ArgumentMetadata): any;
4
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.IntegerValidationPipe = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ let IntegerValidationPipe = class IntegerValidationPipe {
12
+ transform(value, metadata) {
13
+ if (parseInt(value, 10).toString() !== value.toString()) {
14
+ throw new common_1.BadRequestException(`${value} must be an integer`);
15
+ }
16
+ return value;
17
+ }
18
+ };
19
+ exports.IntegerValidationPipe = IntegerValidationPipe;
20
+ exports.IntegerValidationPipe = IntegerValidationPipe = __decorate([
21
+ (0, common_1.Injectable)()
22
+ ], IntegerValidationPipe);
23
+ //# sourceMappingURL=integer.validation.pipe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integer.validation.pipe.js","sourceRoot":"","sources":["../../../src/pipe/integer.validation.pipe.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAKwB;AAGjB,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IACzB,SAAS,CAAC,KAAU,EAAE,QAA0B;QACrD,IAAI,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;YACxD,MAAM,IAAI,4BAAmB,CAAC,GAAG,KAAK,qBAAqB,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AAPY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;GACA,qBAAqB,CAOjC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cryptexlabs/codex-nodejs-common",
3
- "version": "0.10.12",
3
+ "version": "0.10.14",
4
4
  "description": "Common code for Codex framework",
5
5
  "main": "lib/src/index.js",
6
6
  "repository": "git@gitlab.com:cryptexlabs/public/codex-nodejs-common.git",
@@ -0,0 +1,22 @@
1
+ import {
2
+ ArgumentMetadata,
3
+ BadRequestException,
4
+ Injectable,
5
+ PipeTransform,
6
+ } from "@nestjs/common";
7
+ import * as Joi from "joi";
8
+
9
+ @Injectable()
10
+ export class FloatValidationPipe implements PipeTransform {
11
+ private _schema: Joi.Schema;
12
+ constructor() {
13
+ this._schema = Joi.number();
14
+ }
15
+
16
+ public transform(value: any, metadata: ArgumentMetadata): any {
17
+ if (parseFloat(value).toString() !== value.toString()) {
18
+ throw new BadRequestException(`${value} must be a float`);
19
+ }
20
+ return value;
21
+ }
22
+ }
package/src/pipe/index.ts CHANGED
@@ -5,3 +5,5 @@ export * from "./not-empty.pipe";
5
5
  export * from "./joi-http-validation.pipe";
6
6
  export * from "./uuidv4.array.validation.pipe";
7
7
  export * from "./uuidv4.validation.pipe";
8
+ export * from "./integer.validation.pipe";
9
+ export * from "./float.validation.pipe";
@@ -0,0 +1,16 @@
1
+ import {
2
+ ArgumentMetadata,
3
+ BadRequestException,
4
+ Injectable,
5
+ PipeTransform,
6
+ } from "@nestjs/common";
7
+
8
+ @Injectable()
9
+ export class IntegerValidationPipe implements PipeTransform {
10
+ public transform(value: any, metadata: ArgumentMetadata): any {
11
+ if (parseInt(value, 10).toString() !== value.toString()) {
12
+ throw new BadRequestException(`${value} must be an integer`);
13
+ }
14
+ return value;
15
+ }
16
+ }