1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.DefaultValuePipe = void 0;
|
4 | const tslib_1 = require("tslib");
|
5 | const injectable_decorator_1 = require("../decorators/core/injectable.decorator");
|
6 | const shared_utils_1 = require("../utils/shared.utils");
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | let DefaultValuePipe = class DefaultValuePipe {
|
15 | constructor(defaultValue) {
|
16 | this.defaultValue = defaultValue;
|
17 | }
|
18 | transform(value, _metadata) {
|
19 | if ((0, shared_utils_1.isNil)(value) ||
|
20 | ((0, shared_utils_1.isNumber)(value) && isNaN(value))) {
|
21 | return this.defaultValue;
|
22 | }
|
23 | return value;
|
24 | }
|
25 | };
|
26 | exports.DefaultValuePipe = DefaultValuePipe;
|
27 | exports.DefaultValuePipe = DefaultValuePipe = tslib_1.__decorate([
|
28 | (0, injectable_decorator_1.Injectable)(),
|
29 | tslib_1.__metadata("design:paramtypes", [Object])
|
30 | ], DefaultValuePipe);
|