1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const tslib_1 = require("tslib");
|
4 | const bad_request_exception_1 = require("../exceptions/bad-request.exception");
|
5 | const index_1 = require("../index");
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | let ParseIntPipe = class ParseIntPipe {
|
14 | |
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | async transform(value, metadata) {
|
22 | const isNumeric = ['string', 'number'].includes(typeof value) &&
|
23 | !isNaN(parseFloat(value)) &&
|
24 | isFinite(value);
|
25 | if (!isNumeric) {
|
26 | throw new bad_request_exception_1.BadRequestException('Validation failed (numeric string is expected)');
|
27 | }
|
28 | return parseInt(value, 10);
|
29 | }
|
30 | };
|
31 | ParseIntPipe = tslib_1.__decorate([
|
32 | index_1.Injectable()
|
33 | ], ParseIntPipe);
|
34 | exports.ParseIntPipe = ParseIntPipe;
|