class Idcf::Cli::Validate::Custom::MonthCheckValidator
target validator
Constants
- MESSAGES
Public Instance Methods
validate_each(record, attr, val)
click to toggle source
# 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
Protected Instance Methods
format?(val)
click to toggle source
# File lib/idcf/cli/validate/custom/month_check_validator.rb, line 25 def format?(val) !(val =~ /\A\d{4}-\d{1,2}\Z/).nil? end
valid?(val)
click to toggle source
# File lib/idcf/cli/validate/custom/month_check_validator.rb, line 29 def valid?(val) Date.parse("#{val}-01") true rescue StandardError => _e false end