Browse Source
Bugfix/allow GBp in currency code validation (#4640)
* Allow GBp in currency code validation
* Update changelog
pull/4632/head^2
Thomas Kaul
1 day ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
10 additions and
12 deletions
-
CHANGELOG.md
-
apps/api/src/validators/is-currency-code.ts
-
libs/common/src/lib/helper.ts
|
|
@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 |
|
|
|
|
|
|
|
- Improved the language localization for Français (`fr`) |
|
|
|
|
|
|
|
### Fixed |
|
|
|
|
|
|
|
- Fixed the currency code validation by allowing `GBp` |
|
|
|
|
|
|
|
## 2.158.0 - 2025-04-30 |
|
|
|
|
|
|
|
### Added |
|
|
|
|
|
@ -1,4 +1,4 @@ |
|
|
|
import { DERIVED_CURRENCIES } from '@ghostfolio/common/config'; |
|
|
|
import { isDerivedCurrency } from '@ghostfolio/common/helper'; |
|
|
|
|
|
|
|
import { |
|
|
|
registerDecorator, |
|
|
@ -28,17 +28,11 @@ export class IsExtendedCurrencyConstraint |
|
|
|
return '$property must be a valid ISO4217 currency code'; |
|
|
|
} |
|
|
|
|
|
|
|
public validate(currency: any) { |
|
|
|
// Return true if currency is a standard ISO 4217 code or a derived currency
|
|
|
|
public validate(currency: string) { |
|
|
|
// Return true if currency is a derived currency or a standard ISO 4217 code
|
|
|
|
return ( |
|
|
|
this.isUpperCase(currency) && |
|
|
|
(isISO4217CurrencyCode(currency) || |
|
|
|
[ |
|
|
|
...DERIVED_CURRENCIES.map((derivedCurrency) => { |
|
|
|
return derivedCurrency.currency; |
|
|
|
}), |
|
|
|
'USX' |
|
|
|
].includes(currency)) |
|
|
|
isDerivedCurrency(currency) || |
|
|
|
(this.isUpperCase(currency) && isISO4217CurrencyCode(currency)) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -349,7 +349,7 @@ export function isDerivedCurrency(aCurrency: string) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
return DERIVED_CURRENCIES.find(({ currency }) => { |
|
|
|
return DERIVED_CURRENCIES.some(({ currency }) => { |
|
|
|
return currency === aCurrency; |
|
|
|
}); |
|
|
|
} |
|
|
|