Module: Codebreaker::Validation
Constant Summary collapse
- NUMBERS =
/^[1-6]{4}$/
Instance Method Summary collapse
- #validate_guess(code) ⇒ Object
- #validate_name(name) ⇒ Object
- #validate_state(state, current_state) ⇒ Object
Instance Method Details
#validate_guess(code) ⇒ Object
11 12 13 |
# File 'lib/codebreaker/validation/validation.rb', line 11 def validate_guess(code) raise InputError unless NUMBERS.match?(code) end |
#validate_name(name) ⇒ Object
7 8 9 |
# File 'lib/codebreaker/validation/validation.rb', line 7 def validate_name(name) raise LengthError unless Constants::NAME_LENGTH.cover?(name.length) end |
#validate_state(state, current_state) ⇒ Object
15 16 17 |
# File 'lib/codebreaker/validation/validation.rb', line 15 def validate_state(state, current_state) raise StateError unless state == current_state end |