{"record":{"id":"56af4a6bf8bcdf7f","repo":"faker-ruby/faker","slug":"invalid-credit-cards-argument-can-be-left-blank-or","errorCode":null,"errorMessage":"Invalid credit cards argument can be left blank or include #{invalid_cards.join(', ')}","messagePattern":"Invalid credit cards argument can be left blank or include #(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/faker/default/stripe.rb","lineNumber":75,"sourceCode":"\n      ##\n      # Produces a random invalid card number.\n      #\n      # @return [String]\n      #\n      # @example\n      #   Faker::Stripe.invalid_card #=> \"4000000000000002\"\n      #   Faker::Stripe.invalid_card(card_error: \"addressZipFail\") #=> \"4000000000000010\"\n      #\n      # @faker.version 1.9.0\n      def invalid_card(card_error: nil)\n        invalid_cards = translate('faker.stripe.invalid_cards').keys\n\n        if card_error.nil?\n          card_error = sample(invalid_cards).to_s\n        else\n          unless invalid_cards.include?(card_error.to_sym)\n            raise ArgumentError,\n                  \"Invalid credit cards argument can be left blank or include #{invalid_cards.join(', ')}\"\n          end\n        end\n\n        fetch(\"stripe.invalid_cards.#{card_error}\")\n      end\n\n      ##\n      # Produces a random month in two digits format.\n      #\n      # @return [String]\n      #\n      # @example\n      #   Faker::Stripe.month #=> \"10\"\n      #\n      # @faker.version 1.9.0\n      def month\n        format('%02d', rand_in_range(1, 12))","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/faker-ruby/faker/blob/cca4184947e09fdd02afb8b89d25a9c8ebc7274e/lib/faker/default/stripe.rb#L57-L93","documentation":"Raised by Faker::Stripe.invalid_card when card_error is not a key under faker.stripe.invalid_cards in the loaded locale (keys named after Stripe's decline error codes, e.g. :addressZipFail, :incorrectNumber...). The argument is symified then checked against the locale keys; note these keys are camelCase like Stripe's docs, so 'address_zip_fail' or :incorrect_number fail.","triggerScenarios":"Faker::Stripe.invalid_card(card_error: 'addressZipFail') works; card_error: 'address_zip_fail' (snake_case), card_error: 'rateLimit' (if absent from the locale) or any other unknown key raises at lib/faker/default/stripe.rb:75.","commonSituations":"Snake_casing Stripe's camelCase error names (a very common Ruby habit); using a decline code added in newer Stripe docs than the gem's locale data covers; tests iterating over all Stripe decline codes.","solutions":["Omit card_error to get a random invalid card number.","Pass the exact camelCase key shown in the error message, e.g. card_error: 'addressZipFail' (string or symbol).","For decline codes the gem does not ship, take the card number from the error's listed keys or hardcode the number from Stripe's testing docs."],"exampleFix":"# before\nFaker::Stripe.invalid_card(card_error: :address_zip_fail) # ArgumentError\n\n# after\nFaker::Stripe.invalid_card(card_error: :addressZipFail)","handlingStrategy":"validation","validationCode":"valid_errors = I18n.translate('faker.stripe.invalid_cards').keys.map(&:to_s)\ncard_error = nil unless card_error.nil? || valid_errors.include?(card_error.to_s)\nFaker::Stripe.invalid_card(card_error: card_error)","typeGuard":"def known_stripe_card_error?(card_error)\n  I18n.translate('faker.stripe.invalid_cards').key?(card_error.to_s.to_sym)\nend","tryCatchPattern":"begin\n  Faker::Stripe.invalid_card(card_error: card_error)\nrescue ArgumentError\n  Faker::Stripe.invalid_card # random decline\nend","preventionTips":["Stripe decline keys are camelCase (addressZipFail), not snake_case.","Check the locale section for available codes before looping over all Stripe declines.","Omit card_error for a random invalid card."],"tags":["faker","argument-error","enum-whitelist","stripe","payment-testing","camel-case"],"backgroundTag":"invalid-enum-argument","analyzedSha":"cca4184947e09fdd02afb8b89d25a9c8ebc7274e","analyzedAt":"2026-08-21T16:25:39.145Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}