libertarian-party/partynest

View on GitHub
app/validators/timezone_validator.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

class TimezoneValidator < ApplicationEachValidator
  class Validation < Validation
    TIMEZONE_RE = /\A-?\d\d:\d\d:00\z/.freeze

    def perform
      error! :blank if str_value.blank?
      error! :timezone unless TIMEZONE_RE.match? value
    end
  end
end