registration_form_time_validator.rb 328 B

123456789
  1. # frozen_string_literal: true
  2. class RegistrationFormTimeValidator < ActiveModel::Validator
  3. REGISTRATION_FORM_MIN_TIME = 3.seconds.freeze
  4. def validate(user)
  5. user.errors.add(:base, I18n.t('auth.too_fast')) if user.registration_form_time.present? && user.registration_form_time > REGISTRATION_FORM_MIN_TIME.ago
  6. end
  7. end