Module: X::MediaUploadValidator
- Defined in:
- lib/x/media_upload_validator.rb
Overview
Validates media upload parameters
Constant Summary collapse
- MEDIA_CATEGORIES =
Valid media category values
%w[dm_gif dm_image dm_video subtitles tweet_gif tweet_image tweet_video].freeze
Class Method Summary collapse
-
.validate_file_path!(file_path:) ⇒ void
private
Validate that a file path exists.
-
.validate_media_category!(media_category:) ⇒ void
private
Validate that a media category is valid.
Class Method Details
.validate_file_path!(file_path:) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Validate that a file path exists
18 19 20 |
# File 'lib/x/media_upload_validator.rb', line 18 def validate_file_path!(file_path:) raise "File not found: #{file_path}" unless File.exist?(file_path) end |
.validate_media_category!(media_category:) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Validate that a media category is valid
30 31 32 33 34 |
# File 'lib/x/media_upload_validator.rb', line 30 def validate_media_category!(media_category:) return if MEDIA_CATEGORIES.include?(media_category.downcase) raise ArgumentError, "Invalid media_category: #{media_category}. Valid values: #{MEDIA_CATEGORIES.join(", ")}" end |