Class: BooleanFormatValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- BooleanFormatValidator
- Defined in:
- lib/csv_row_model/validators/boolean_format.rb
Overview
:nodoc:
Constant Summary collapse
- FALSE_BOOLEAN_REGEX =
/^(false|f|no|n|0|)$/i- TRUE_BOOLEAN_REGEX =
/^(true|t|yes|y|1)$/i
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
6 7 8 9 10 |
# File 'lib/csv_row_model/validators/boolean_format.rb', line 6 def validate_each(record, attribute, value) return if value =~ FALSE_BOOLEAN_REGEX || value =~ TRUE_BOOLEAN_REGEX record.errors.add(attribute, 'is not a Boolean format') end |