{"record":{"id":"ecc0ee84b090f9d5","repo":"dotnet/aspnetcore","slug":"unknown-name-value-val","errorCode":null,"errorMessage":"Unknown ${name} value: ${val}.","messagePattern":"Unknown (.+?) value: (.+?)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/SignalR/clients/ts/signalr/src/Utils.ts","lineNumber":32,"sourceCode":"\nexport { VERSION };\n/** @private */\nexport class Arg {\n    public static isRequired(val: any, name: string): void {\n        if (val === null || val === undefined) {\n            throw new Error(`The '${name}' argument is required.`);\n        }\n    }\n    public static isNotEmpty(val: string, name: string): void {\n        if (!val || val.match(/^\\s*$/)) {\n            throw new Error(`The '${name}' argument should not be empty.`);\n        }\n    }\n\n    public static isIn(val: any, values: any, name: string): void {\n        // TypeScript enums have keys for **both** the name and the value of each enum member on the type itself.\n        if (!(val in values)) {\n            throw new Error(`Unknown ${name} value: ${val}.`);\n        }\n    }\n}\n\n/** @private */\nexport class Platform {\n    // react-native has a window but no document so we should check both\n    public static get isBrowser(): boolean {\n        return !Platform.isNode && typeof window === \"object\" && typeof window.document === \"object\";\n    }\n\n    // WebWorkers don't have a window object so the isBrowser check would fail\n    public static get isWebWorker(): boolean {\n        return !Platform.isNode && typeof self === \"object\" && \"importScripts\" in self;\n    }\n\n    // react-native has a window but no document\n    static get isReactNative(): boolean {","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/SignalR/clients/ts/signalr/src/Utils.ts#L14-L50","documentation":"Arg.isIn checks that a value is a valid member of a TypeScript enum (TransferFormat, HttpTransportType) by testing membership in the enum object. It throws for any value outside the known enum set, catching invalid numeric or string selections early.","triggerScenarios":"Passing a transport type or transfer format value not present in the enum, e.g. withUrl(url, 99) or a numeric value that does not map to HttpTransportType.","commonSituations":"Wrong numeric literal, an enum value that changed across versions, or feeding a user-controlled number straight into the API without validation.","solutions":["Pass a value from the enum itself, e.g. HttpTransportType.WebSockets, not a raw number.","Validate user-supplied transport selections against the enum before calling withUrl.","Update the client package if enum values changed in a newer version.","Default to HttpTransportType.None to let SignalR negotiate a supported transport."],"exampleFix":"// before\nwithUrl(url, 99); // not in HttpTransportType\n\n// after\nwithUrl(url, HttpTransportType.WebSockets);","handlingStrategy":"validation","validationCode":"function requireEnum<T extends object>(val: unknown, enumObj: T, name: string): void {\n  if (!(val in enumObj)) {\n    throw new Error(`Unknown ${name} value: ${String(val)}`);\n  }\n}","typeGuard":"function isTransferFormat(v: unknown): v is TransferFormat {\n  return v === TransferFormat.Text || v === TransferFormat.Binary;\n}","tryCatchPattern":null,"preventionTips":["Pass enum members (e.g. HttpTransportType.WebSockets), not raw numbers.","Whitelist user-supplied transport choices before forwarding to SignalR.","Default to HttpTransportType.None so SignalR negotiates a valid transport."],"tags":["typescript","signalr","validation","argument-validation","enum"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}