Class: Dragnet::Validators::Fields::ResultValidator
- Inherits:
-
FieldValidator
- Object
- FieldValidator
- Dragnet::Validators::Fields::ResultValidator
- Defined in:
- lib/dragnet/validators/fields/result_validator.rb
Overview
Validates the result field of an MTR Record
Constant Summary collapse
- VALID_RESULTS =
%w[passed failed].freeze
Instance Method Summary collapse
-
#validate(key, value) ⇒ String
Validates the MTR's result.
Instance Method Details
#validate(key, value) ⇒ String
Validates the MTR's result
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dragnet/validators/fields/result_validator.rb', line 18 def validate(key, value) validate_presence(key, value) validate_type(key, value, String) value = value.downcase return value if VALID_RESULTS.include?(value) validation_error( "Invalid value for key result: '#{value}'. "\ "Valid values are #{VALID_RESULTS.join(', ')}" ) end |