Skip to content

Commit

Permalink
restrict values for base
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeragamba committed Jul 2, 2020
1 parent 5de66cb commit fe963d6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/faker/default/code.rb
Expand Up @@ -34,7 +34,11 @@ def isbn(legacy_base = NOT_GIVEN, base: 10)
keywords << :base if legacy_base != NOT_GIVEN
end

base == 13 ? generate_base13_isbn : generate_base10_isbn
case base
when 10 then generate_base10_isbn
when 13 then generate_base13_isbn
else raise ArgumentError, 'base must be 10, or 13'
end
end

##
Expand All @@ -54,7 +58,11 @@ def ean(legacy_base = NOT_GIVEN, base: 13)
keywords << :base if legacy_base != NOT_GIVEN
end

base == 8 ? generate_base8_ean : generate_base13_ean
case base
when 8 then generate_base8_ean
when 13 then generate_base13_ean
else raise ArgumentError, 'base must be 3, or 13'
end
end

##
Expand Down Expand Up @@ -165,8 +173,6 @@ def sin
def generate_imei
str = Array.new(15, 0)
sum = 0
t = 0
len_offset = 0
len = 15

# Fill in the first two values of the string based with the specified prefix.
Expand Down

0 comments on commit fe963d6

Please sign in to comment.