Module: Codebreaker::Mixins::Validator

Included in:
Player
Defined in:
lib/codebreaker/mixins/validator.rb

Instance Method Summary collapse

Instance Method Details

#validate_length(value, min, max) ⇒ Object



4
5
6
7
8
9
# File 'lib/codebreaker/mixins/validator.rb', line 4

def validate_length(value, min, max)
  return if value.instance_of?(String) && value.size.between?(min, max)

  raise Codebreaker::Errors::ValidationLengthError,
        I18n.t('errors.validation_length_detailed', value: value, min: min, max: max)
end