Class: Gitlab::Config::Entry::Validators::DurationValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Includes:
LegacyValidationHelpers
Defined in:
lib/gitlab/config/entry/validators.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object


108
109
110
111
112
113
114
115
116
117
118
# File 'lib/gitlab/config/entry/validators.rb', line 108

def validate_each(record, attribute, value)
  unless validate_duration(value, options[:parser])
    record.errors.add(attribute, 'should be a duration')
  end

  if options[:limit]
    unless validate_duration_limit(value, options[:limit], options[:parser])
      record.errors.add(attribute, 'should not exceed the limit')
    end
  end
end