faker-ruby/faker · error · ArgumentError

min_length must be smaller than or equal to max_length

Error message

min_length must be smaller than or equal to max_length

What it means

Error "min_length must be smaller than or equal to max_length" thrown in faker-ruby/faker.

Source

Thrown at lib/faker/internet.rb:132

      # @param special_characters [Boolean] Toggles if special characters are allowed. If true, at least one will be added.
      #
      # @return [String]
      #
      # @example
      #   Faker::Internet.password #=> "Vg5mSvY1UeRg7"
      # @example
      #   Faker::Internet.password(min_length: 8) #=> "YfGjIk0hGzDqS0"
      # @example
      #   Faker::Internet.password(min_length: 10, max_length: 20) #=> "EoC9ShWd1hWq4vBgFw"
      # @example
      #   Faker::Internet.password(min_length: 10, max_length: 20, mix_case: true) #=> "3k5qS15aNmG"
      # @example
      #   Faker::Internet.password(min_length: 10, max_length: 20, mix_case: true, special_characters: true) #=> "*%NkOnJsH4"
      #
      # @faker.version 2.1.3
      def password(min_length: 8, max_length: 16, mix_case: true, special_characters: false)
        raise ArgumentError, 'min_length and max_length must be greater than or equal to one' if min_length < 1 || max_length < 1
        raise ArgumentError, 'min_length must be smaller than or equal to max_length' unless min_length <= max_length

        character_types = []
        required_min_length = 0

        if mix_case
          character_types << :mix_case
          required_min_length += 2
        end

        if special_characters
          character_types << :special_characters
          required_min_length += 1
        end

        raise ArgumentError, "min_length should be at least #{required_min_length} to enable #{character_types.join(', ')} configuration" if min_length < required_min_length

        target_length = rand(min_length..max_length)

View on GitHub (pinned to cca4184947)

When it happens

Trigger: Thrown at lib/faker/internet.rb:132 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of faker-ruby/faker@cca4184947 (2026-08-21). Data as JSON: /api/errors/bbf5e63119644745. Report an issue: GitHub.