{"record":{"id":"18f1c616c34ee9b1","repo":"bchavez/Bogus","slug":"registrationnumbertype-is-not-a-supported-na","errorCode":null,"errorMessage":"[{registrationNumberType}] is not a supported [{nameof(VatRegistrationNumberType)}].","messagePattern":"\\[(.+?)\\] is not a supported \\[(.+?)\\]\\.","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"Source/Bogus/Extensions/UnitedKingdom/ExtensionsForUnitedKingdom.cs","lineNumber":120,"sourceCode":"               ? $\"GB HA {random:000}\"\n               : $\"GBHA{random:000}\";\n         case VatRegistrationNumberType.GovernmentDepartment:\n            return includeSeparator\n               ? $\"GB GD {random:000}\"\n               : $\"GBGD{random:000}\";\n         case VatRegistrationNumberType.Standard:\n            int checksum = CalculateChecksum(random);\n            return includeSeparator\n               ? $\"GB {random:000 0000} {checksum:00}\"\n               : $\"GB{random:0000000}{checksum:00}\";\n         case VatRegistrationNumberType.BranchTrader:\n            checksum = CalculateChecksum(random);\n            string suffix = finance.Random.ReplaceNumbers(\"###\");\n            return includeSeparator\n               ? $\"GB {random:000 0000} {checksum:00} {suffix}\"\n               : $\"GB{random:0000000}{checksum:00}{suffix}\";\n         default:\n            throw new NotImplementedException($\"[{registrationNumberType}] is not a supported [{nameof(VatRegistrationNumberType)}].\");\n      }\n   }\n\n   private static int CalculateChecksum(int n)\n   {\n      int total = 0;\n      int divisor = 1;\n\n      while( n / divisor >= 10 )\n      {\n         divisor *= 10;\n      }\n\n      int index = 0;\n      while( divisor > 0 )\n      {\n         int digit = n / divisor;\n         total += digit * (8 - index);","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/bchavez/Bogus/blob/6ece18c5c22648ab4606e45a0aaf2f07fc5259e4/Source/Bogus/Extensions/UnitedKingdom/ExtensionsForUnitedKingdom.cs#L102-L138","documentation":"Finance.VatRegistrationNumber switch handles Standard and BranchTrader but throws NotImplementedException for any other VatRegistrationNumberType. (GovernmentDepartment and HealthAuthority are handled in the actual source, so the reachable trigger is an enum value supplied via an invalid cast, e.g. (VatRegistrationNumberType)99.) The guard is defensive against undefined enum inputs.","triggerScenarios":"Calling finance.VatRegistrationNumber((VatRegistrationNumberType)99) or any int cast to the enum that is not 0-3. With valid named enum values the guard is not reached.","commonSituations":"Deserializing a numeric type code into VatRegistrationNumberType without bounds checking, or an enum-extension scenario where a new member was added but not yet cased.","solutions":["Use one of the defined enum values: Standard, BranchTrader, GovernmentDepartment, HealthAuthority.","If the value comes from an int, validate Enum.IsDefined(typeof(VatRegistrationNumberType), value) first.","Treat NotImplementedException as a signal that an unsupported/invalid enum was passed and surface a clearer error to the caller."],"exampleFix":"// before\nvar vat = finance.VatRegistrationNumber((VatRegistrationNumberType)typeId);\n\n// after\nif (!Enum.IsDefined(typeof(VatRegistrationNumberType), typeId))\n    throw new ArgumentException(\"Unknown VAT registration type\");\nvar vat = finance.VatRegistrationNumber((VatRegistrationNumberType)typeId);","handlingStrategy":"validation","validationCode":"if (!Enum.IsDefined(typeof(VatRegistrationNumberType), registrationNumberType))\n    throw new ArgumentOutOfRangeException(nameof(registrationNumberType));\nvar vat = finance.VatRegistrationNumber(registrationNumberType);","typeGuard":"static bool IsKnownVatType(VatRegistrationNumberType t) => Enum.IsDefined(typeof(VatRegistrationNumberType), t);","tryCatchPattern":"try { return finance.VatRegistrationNumber(type); }\ncatch (NotImplementedException) { throw new ArgumentException($\"Unsupported VAT type {type}\"); }","preventionTips":["Use the four defined enum values only.","Validate Enum.IsDefined when the value comes from an int.","Treat NotImplementedException here as an invalid-enum signal and rethrow a clearer error."],"tags":["united-kingdom","vat","enum","not-implemented","finance"],"backgroundTag":null,"analyzedSha":"6ece18c5c22648ab4606e45a0aaf2f07fc5259e4","analyzedAt":"2026-08-13T21:08:15.463Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}