Class: CoronaPresenceTracing::CWACheckInValidator

Inherits:
CheckInValidator show all
Defined in:
lib/corona_presence_tracing/validator.rb

Constant Summary collapse

ALLOWED_LOCATION_TYPES =
%i[
  permanent_retail permanent_food_service permanent_craft permanent_workplace
  permanent_educational_institution permanent_public_building permanent_other
  temporary_cultural_event temporary_club_activity temporary_private_event
  temporary_worship_service temporary_other
].freeze

Instance Method Summary collapse

Methods inherited from CheckInValidator

#initialize

Constructor Details

This class inherits a constructor from CoronaPresenceTracing::CheckInValidator

Instance Method Details

#temporary_location?Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/corona_presence_tracing/validator.rb', line 103

def temporary_location?
  @check_in.location_type.to_s.start_with?('temporary')
end

#validateObject



89
90
91
92
93
94
95
96
# File 'lib/corona_presence_tracing/validator.rb', line 89

def validate
  validate_type_of :location_type, %w[Symbol String]
  validate_inclusion_of :location_type, ALLOWED_LOCATION_TYPES
  validate_presence_of :default_check_in_length unless temporary_location?
  validate_type_of :default_check_in_length, %w[Integer]
  validate_inclusion_of :default_check_in_length, (0..1440)
  super
end

#validate_datesObject



98
99
100
101
# File 'lib/corona_presence_tracing/validator.rb', line 98

def validate_dates
  validate_presence_of :start_time, :end_time if temporary_location?
  super
end