|
@ -1,4 +1,4 @@ |
|
|
import { DERIVED_CURRENCIES } from '@ghostfolio/common/config'; |
|
|
import { isDerivedCurrency } from '@ghostfolio/common/helper'; |
|
|
|
|
|
|
|
|
import { |
|
|
import { |
|
|
registerDecorator, |
|
|
registerDecorator, |
|
@ -28,17 +28,11 @@ export class IsExtendedCurrencyConstraint |
|
|
return '$property must be a valid ISO4217 currency code'; |
|
|
return '$property must be a valid ISO4217 currency code'; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public validate(currency: any) { |
|
|
public validate(currency: string) { |
|
|
// Return true if currency is a standard ISO 4217 code or a derived currency
|
|
|
// Return true if currency is a derived currency or a standard ISO 4217 code
|
|
|
return ( |
|
|
return ( |
|
|
this.isUpperCase(currency) && |
|
|
isDerivedCurrency(currency) || |
|
|
(isISO4217CurrencyCode(currency) || |
|
|
(this.isUpperCase(currency) && isISO4217CurrencyCode(currency)) |
|
|
[ |
|
|
|
|
|
...DERIVED_CURRENCIES.map((derivedCurrency) => { |
|
|
|
|
|
return derivedCurrency.currency; |
|
|
|
|
|
}), |
|
|
|
|
|
'USX' |
|
|
|
|
|
].includes(currency)) |
|
|
|
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|