@bitloops/bl-boilerplate-core
Version:
TypeScript boilerplate code for Bitloops Language generated projects
27 lines (26 loc) • 833 B
JavaScript
import { AVAILABLE_CURRENCY_STANDARDS, ISO_4217_CURRENCY_CODES } from '../Currency';
import { CurrencyCodeDoesNotExistError, CurrencyStandardDoesNotExistError } from '../errors';
export class CurrencyShouldExistRule {
currencyCode;
constructor(currencyCode) {
this.currencyCode = currencyCode;
}
Error = new CurrencyCodeDoesNotExistError(this.currencyCode);
isBrokenIf() {
if (!ISO_4217_CURRENCY_CODES[this.currencyCode])
return true;
return false;
}
}
export class ISOShouldBeSupportedRule {
standard;
constructor(standard) {
this.standard = standard;
}
Error = new CurrencyStandardDoesNotExistError(this.standard);
isBrokenIf() {
if (!AVAILABLE_CURRENCY_STANDARDS[this.standard])
return true;
return false;
}
}