Class: Edoxen::VenueValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/edoxen/venue_validator.rb,
sig/edoxen.rbs

Overview

VenueValidator — validates Venue instances using the unlocodes and iata gems. Returns a list of errors; empty list means valid.

For PhysicalVenue with a unlocode or iata_code field, validates that the code exists in the canonical registries. Optionally auto-populates city/country_code/coordinates from the registry.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(venue) ⇒ VenueValidator

Returns a new instance of VenueValidator.

Parameters:



13
14
15
16
# File 'lib/edoxen/venue_validator.rb', line 13

def initialize(venue)
  @venue = venue
  @errors = []
end

Instance Attribute Details

#errorsArray[String] (readonly)

Returns the value of attribute errors.

Returns:

  • (Array[String])


11
12
13
# File 'lib/edoxen/venue_validator.rb', line 11

def errors
  @errors
end

#venueVenue (readonly)

Returns the value of attribute venue.

Returns:



11
12
13
# File 'lib/edoxen/venue_validator.rb', line 11

def venue
  @venue
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


24
25
26
27
# File 'lib/edoxen/venue_validator.rb', line 24

def valid?
  validate
  errors.empty?
end

#validate(auto_populate: false) ⇒ Array[String]

Parameters:

  • auto_populate: (Boolean) (defaults to: false)

Returns:

  • (Array[String])


18
19
20
21
22
# File 'lib/edoxen/venue_validator.rb', line 18

def validate(auto_populate: false)
  validate_physical(auto_populate: auto_populate) if venue.physical?

  errors
end