Module: AlexCodebreaker::Modules::Validators

Included in:
ArgumentsValidation
Defined in:
lib/alex_codebreaker/modules/validators.rb

Instance Method Summary collapse

Instance Method Details

#argument_length_check(arg, length) ⇒ Object



4
5
6
# File 'lib/alex_codebreaker/modules/validators.rb', line 4

def argument_length_check(arg, length)
  arg.to_s.length == length
end

#argument_max_length_check(arg, max) ⇒ Object



8
9
10
# File 'lib/alex_codebreaker/modules/validators.rb', line 8

def argument_max_length_check(arg, max)
  arg.length <= max
end

#argument_min_length_check(arg, min) ⇒ Object



12
13
14
# File 'lib/alex_codebreaker/modules/validators.rb', line 12

def argument_min_length_check(arg, min)
  arg.length >= min
end

#digits_check(arg, min_digit, max_digit) ⇒ Object



16
17
18
# File 'lib/alex_codebreaker/modules/validators.rb', line 16

def digits_check(arg, min_digit, max_digit)
  arg.split('').all? { |value| value.to_i.between?(min_digit, max_digit) }
end