Class: Idcf::Cli::Validate::Custom::MonthCheckValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- Idcf::Cli::Validate::Custom::MonthCheckValidator
- Defined in:
- lib/idcf/cli/validate/custom/month_check_validator.rb
Overview
target validator
Constant Summary collapse
- MESSAGES =
{ format: 'different format ex)YYYY-MM', invalid: 'An invalid date' }.freeze
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attr, val) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/idcf/cli/validate/custom/month_check_validator.rb', line 16 def validate_each(record, attr, val) str = MESSAGES[:format] return record.errors.add(attr, str, **{}) unless format?(val) str = MESSAGES[:invalid] return record.errors.add(attr, str, **{}) unless valid?(val) end |