1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.getDefaultValue = void 0;
|
4 | const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
5 | const lodash_1 = require("lodash");
|
6 | const default_values_conflict_error_1 = require("../errors/default-values-conflict.error");
|
7 | function getDefaultValue(instance, options, key, typeName) {
|
8 | const initializerValue = instance[key];
|
9 | if ((0, shared_utils_1.isUndefined)(options.defaultValue)) {
|
10 | return initializerValue;
|
11 | }
|
12 | if (!(0, lodash_1.isEqual)(options.defaultValue, initializerValue) &&
|
13 | !(0, shared_utils_1.isUndefined)(initializerValue)) {
|
14 | throw new default_values_conflict_error_1.DefaultValuesConflictError(typeName, key, options.defaultValue, initializerValue);
|
15 | }
|
16 | return options.defaultValue;
|
17 | }
|
18 | exports.getDefaultValue = getDefaultValue;
|