mirror of https://github.com/ghostfolio/ghostfolio
9 changed files with 168 additions and 6 deletions
@ -0,0 +1,12 @@ |
|||
import { IsISO8601, IsNumber, Validate } from 'class-validator'; |
|||
|
|||
import { IsSplitFactorConstraint } from '../validator-constraints/is-split-factor'; |
|||
|
|||
export class CreateAssetProfileSplitDto { |
|||
@IsISO8601() |
|||
date: string; |
|||
|
|||
@IsNumber() |
|||
@Validate(IsSplitFactorConstraint) |
|||
factor: number; |
|||
} |
|||
@ -1,8 +1,9 @@ |
|||
import { MarketData } from '@prisma/client'; |
|||
import { AssetProfileSplit, MarketData } from '@prisma/client'; |
|||
|
|||
import { EnhancedAssetProfile } from './enhanced-asset-profile.interface'; |
|||
|
|||
export interface AdminMarketDataDetails { |
|||
assetProfile: Partial<EnhancedAssetProfile>; |
|||
marketData: MarketData[]; |
|||
splits: AssetProfileSplit[]; |
|||
} |
|||
|
|||
@ -1,8 +1,9 @@ |
|||
import { MarketData } from '@prisma/client'; |
|||
import { AssetProfileSplit, MarketData } from '@prisma/client'; |
|||
|
|||
import { EnhancedAssetProfile } from '../enhanced-asset-profile.interface'; |
|||
|
|||
export interface AssetProfileResponse { |
|||
assetProfile: Partial<EnhancedAssetProfile>; |
|||
marketData: MarketData[]; |
|||
splits: AssetProfileSplit[]; |
|||
} |
|||
|
|||
@ -0,0 +1,15 @@ |
|||
import { |
|||
ValidatorConstraint, |
|||
ValidatorConstraintInterface |
|||
} from 'class-validator'; |
|||
|
|||
@ValidatorConstraint({ name: 'isSplitFactor' }) |
|||
export class IsSplitFactorConstraint implements ValidatorConstraintInterface { |
|||
public defaultMessage() { |
|||
return 'factor must be a positive number other than 1'; |
|||
} |
|||
|
|||
public validate(aFactor: number) { |
|||
return typeof aFactor === 'number' && aFactor > 0 && aFactor !== 1; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue