Browse Source

feat(targets): integrate validated settings into user preferences

pull/8458/head
PJ 4 days ago
parent
commit
976d03ead4
  1. 16
      libs/common/src/lib/dtos/update-user-setting.dto.ts

16
libs/common/src/lib/dtos/update-user-setting.dto.ts

@ -1,4 +1,4 @@
import { XRayRulesSettings } from '@ghostfolio/common/interfaces'; import { PortfolioTargetsSettings, XRayRulesSettings } from '@ghostfolio/common/interfaces';
import type { import type {
ColorScheme, ColorScheme,
DateRange, DateRange,
@ -6,6 +6,7 @@ import type {
ViewMode ViewMode
} from '@ghostfolio/common/types'; } from '@ghostfolio/common/types';
import { PerformanceCalculationType } from '@ghostfolio/common/types/performance-calculation-type.type'; import { PerformanceCalculationType } from '@ghostfolio/common/types/performance-calculation-type.type';
import { isValidPortfolioTargetsSettings } from '@ghostfolio/common/portfolio-targets/portfolio-targets-validation';
import { IsCurrencyCode } from '@ghostfolio/common/validators/is-currency-code'; import { IsCurrencyCode } from '@ghostfolio/common/validators/is-currency-code';
import { import {
@ -15,7 +16,8 @@ import {
IsIn, IsIn,
IsNumber, IsNumber,
IsOptional, IsOptional,
IsString IsString,
ValidateBy
} from 'class-validator'; } from 'class-validator';
import { eachYearOfInterval, format } from 'date-fns'; import { eachYearOfInterval, format } from 'date-fns';
@ -109,6 +111,16 @@ export class UpdateUserSettingDto {
* The target financial amount the user aims to reach before retiring. * The target financial amount the user aims to reach before retiring.
* Can be explicitly set to null to clear the value and calculate it dynamically. * Can be explicitly set to null to clear the value and calculate it dynamically.
*/ */
@IsOptional()
@ValidateBy({
name: 'isValidPortfolioTargetsSettings',
validator: {
validate: isValidPortfolioTargetsSettings,
defaultMessage: () => 'portfolioTargets must contain one valid global target allocation'
}
})
portfolioTargets?: PortfolioTargetsSettings;
@IsNumber() @IsNumber()
@IsOptional() @IsOptional()
projectedTotalAmount?: number | null; projectedTotalAmount?: number | null;

Loading…
Cancel
Save