Chore: formatting

This commit is contained in:
Pieter Vander Vennet 2024-06-16 16:06:26 +02:00
parent 35eff07c80
commit c08fe03ed0
422 changed files with 31594 additions and 43019 deletions

View file

@ -63,7 +63,7 @@ export default class Validators {
"slope",
"velopark",
"nsi",
"currency"
"currency",
] as const
public static readonly AllValidators: ReadonlyArray<Validator> = [
@ -94,7 +94,7 @@ export default class Validators {
new SlopeValidator(),
new VeloparkValidator(),
new NameSuggestionIndexValidator(),
new CurrencyValidator()
new CurrencyValidator(),
]
private static _byType = Validators._byTypeConstructor()

View file

@ -13,26 +13,26 @@ export default class CurrencyValidator extends Validator {
return
}
let locale = "en-US"
if(!Utils.runningFromConsole){
locale??= navigator.language
if (!Utils.runningFromConsole) {
locale ??= navigator.language
}
this.segmenter = new Intl.Segmenter(locale, {
granularity: "word"
granularity: "word",
})
const mapping: Map<string, string> = new Map<string, string>()
const supportedCurrencies: Set<string> = new Set(Intl.supportedValuesOf("currency"))
this.supportedCurrencies = supportedCurrencies
for (const currency of supportedCurrencies) {
const symbol = (0).toLocaleString(
locale,
{
const symbol = (0)
.toLocaleString(locale, {
style: "currency",
currency: currency,
minimumFractionDigits: 0,
maximumFractionDigits: 0
}
).replace(/\d/g, "").trim()
maximumFractionDigits: 0,
})
.replace(/\d/g, "")
.trim()
mapping.set(symbol.toLowerCase(), currency)
}
@ -44,8 +44,10 @@ export default class CurrencyValidator extends Validator {
return s
}
const parts = Array.from(this.segmenter.segment(s)).map(i => i.segment).filter(part => part.trim().length > 0)
if(parts.length !== 2){
const parts = Array.from(this.segmenter.segment(s))
.map((i) => i.segment)
.filter((part) => part.trim().length > 0)
if (parts.length !== 2) {
return s
}
const mapping = this.symbolToCurrencyMapping
@ -64,10 +66,10 @@ export default class CurrencyValidator extends Validator {
}
amount = part
}
if(amount === undefined || currency === undefined){
if (amount === undefined || currency === undefined) {
return s
}
return amount+" "+currency
return amount + " " + currency
}
}

View file

@ -3,7 +3,10 @@ import UrlValidator from "./UrlValidator"
export default class VeloparkValidator extends UrlValidator {
constructor() {
super("velopark", "A special URL-validator that checks the domain name and rewrites to the correct velopark format.")
super(
"velopark",
"A special URL-validator that checks the domain name and rewrites to the correct velopark format."
)
}
getFeedback(s: string): Translation {