Class: Netfira::WebConnect::Model::Record::FileRecord::Validator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
lib/netfira/web_connect/model/record/file_record.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.remote_file_sources_filterObject



29
30
31
# File 'lib/netfira/web_connect/model/record/file_record.rb', line 29

def self.remote_file_sources_filter
  @remote_file_sources_filter ||= Regexp.new(ENV['REMOTE_FILE_SOURCES_FILTER'] || '^https?://', Regexp::IGNORECASE)
end

Instance Method Details

#validate(record) ⇒ Object



32
33
34
35
36
# File 'lib/netfira/web_connect/model/record/file_record.rb', line 32

def validate(record)
  if record.remote_location && !(record.remote_location =~ self.class.remote_file_sources_filter)
    record.errors[:remote_location] << 'Unacceptable format'
  end
end