fix enum value deserialization (#609)

This commit is contained in:
Aleksei Bezrodnov 2023-06-13 21:04:56 +02:00 committed by GitHub
parent 2537ded3c2
commit 192c1947a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -41,7 +41,11 @@ class EnumHelper<EnumObj extends object, EnumMember extends Member<EnumObj> & st
fuzzyGetMember(input: string): EnumMember | undefined;
fuzzyGetMember(input: string, alwaysMatch: true): EnumMember;
fuzzyGetMember(input: string, alwaysMatch = false) {
return this.fuzzMap.get(input.toLowerCase().replace(/[ -]+/g, "")) ?? alwaysMatch ? this.valueArray[0] : undefined;
const matchedValue = this.fuzzMap.get(input.toLowerCase().replace(/[ -]+/g, ""));
if (matchedValue) {
return matchedValue;
}
return alwaysMatch ? this.valueArray[0] : undefined;
}
/** Provide a case sensitive match, or undefined if */
getMember(input: unknown): EnumMember | undefined {