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


143
144
145
146
147
148
149
150
151
152
153
# File 'lib/gitlab/config/entry/validators.rb', line 143

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