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



155
156
157
158
159
160
161
162
163
164
165
# File 'lib/gitlab/config/entry/validators.rb', line 155

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