{"record":{"id":"e4b895b8e4abd7ce","repo":"faker-ruby/faker","slug":"day-of-week-cannot-be-empty","errorCode":null,"errorMessage":"Day of week cannot be empty","messagePattern":"Day of week cannot be empty","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/faker/default/date.rb","lineNumber":158,"sourceCode":"\n      ##\n      # Produce a random date at given day(s) of the week between two dates.\n      #\n      # @param day [Symbol, Array<Symbol>] # The day(s) of the week. See {DAYS_OF_WEEK}.\n      # @param from [Date, String] The start of the usable date range.\n      # @param to [Date, String] The end of the usable date range.\n      # @return [Date]\n      #\n      # @example if used with or without Rails (Active Support)\n      #   Faker::Date.on_day_of_week_between(day: :tuesday, from: '2023-01-01', to: '2023-02-01') #=> #<Date: 2032-01-10>\n      #\n      # @example if used with Rails (Active Support)\n      #   Faker::Date.on_day_of_week_between(day: [:saturday, :sunday], from: 1.month.ago, to: Date.today) #=> #<Date: 2014-09-24>\n      #\n      # @faker.version next\n      def on_day_of_week_between(day:, from:, to:)\n        days = [day].flatten\n        raise ArgumentError, 'Day of week cannot be empty' if days.empty?\n\n        # Convert given days of the week to numbers used by `Date#wday` method\n        numeric_weekdays = days.map do |d|\n          DAYS_OF_WEEK.index(d.to_sym.downcase) || raise(ArgumentError, \"#{d} is not a valid day of the week\")\n        end\n\n        from = get_date_object(from)\n        to   = get_date_object(to)\n        date = Faker::Base.rand_in_range(from, to)\n\n        # If the initial date is not on one of the wanted days of the week...\n        unless numeric_weekdays.include? date.wday\n          # ...pick a date nearby that is on one of the wanted days of the week instead\n          date += sample(numeric_weekdays) - date.wday\n\n          # Move date 1 week earlier or later if the adjusted date is now outside the date range\n          date += 7 if date < from\n          date -= 7 if date > to","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/faker-ruby/faker/blob/cca4184947e09fdd02afb8b89d25a9c8ebc7274e/lib/faker/default/date.rb#L140-L176","documentation":"Error \"Day of week cannot be empty\" thrown in faker-ruby/faker.","triggerScenarios":"Thrown at lib/faker/default/date.rb:158 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"cca4184947e09fdd02afb8b89d25a9c8ebc7274e","analyzedAt":"2026-08-21T16:25:39.145Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}