Skip to main content
The Deno 2 Release Candidate is here
Learn more
method TraderHelper.prototype.getValidTraderIdByEnumValue
import { TraderHelper } from "https://deno.land/x/sptaki@1.2.0/helpers/TraderHelper.d.ts";

Validates that the provided traderEnumValue exists in the Traders enum. If the value is valid, it returns the same enum value, effectively serving as a trader ID; otherwise, it logs an error and returns an empty string. This method provides a runtime check to prevent undefined behavior when using the enum as a dictionary key.

For example, instead of this: const traderId = Traders[Traders.PRAPOR];

You can use safely use this: const traderId = this.traderHelper.getValidTraderIdByEnumValue(Traders.PRAPOR);

Parameters

traderEnumValue: Traders

The trader enum value to validate

Returns

string

The validated trader enum value as a string, or an empty string if invalid