Class: Html2rss::Config::Validator
- Inherits:
-
Dry::Validation::Contract
- Object
- Dry::Validation::Contract
- Html2rss::Config::Validator
- Defined in:
- lib/html2rss/config/validator.rb
Overview
Validates the configuration hash using Dry::Validation. The configuration options adhere to the documented schema in README.md.
Defined Under Namespace
Classes: BotasaurusRequestExport
Constant Summary collapse
- URI_REGEXP =
URI format used for channel URL validation.
Url::URI_REGEXP
- STYLESHEET_TYPES =
Allowed stylesheet MIME types.
FeedBuilder::Rss::Stylesheet::TYPES
- LANGUAGE_FORMAT_REGEX =
Optional language/region format (
enoren-US). /\A[a-z]{2}(-[A-Z]{2})?\z/- BASE_STRATEGY_OPTIONS =
Baseline strategy-plan enum (:auto plus concrete RequestService strategies).
Html2rss::FeedPipeline::StrategyPlan.accepted_names.freeze
- DIRECTORY_TOPICS =
Controlled vocabulary for catalog-only
directory.topics(not RSS channel fields). %w[ sports energy tech science news entertainment jobs finance security travel environment consumer civic product research ].freeze
- ChannelConfig =
Contract for the top-level
channelsection. Dry::Schema.Params do required(:url).filled(:string, format?: URI_REGEXP) optional(:title).maybe(:string) optional(:description).maybe(:string) optional(:language).maybe(:string, format?: LANGUAGE_FORMAT_REGEX) optional(:ttl).maybe(:integer, gt?: 0) optional(:time_zone).maybe(:string) optional(:author).maybe(:string) optional(:image).maybe(:string, format?: URI_REGEXP) end
- DirectoryConfig =
Contract for catalog-only
directorymetadata (topics for feed directories). Dry::Schema.Params do optional(:topics).value(:array, min_size?: 1).each(:string, included_in?: DIRECTORY_TOPICS) end
- StylesheetConfig =
Contract for a stylesheet entry in
stylesheets. Dry::Schema.Params do required(:href).filled(:string) required(:type).filled(:string, included_in?: STYLESHEET_TYPES) optional(:media).maybe(:string) end
- BotasaurusRequestConfig =
Contract for Botasaurus-specific request options (OpenAPI ScrapeRequest minus url).
Dry::Schema.Params do config.validate_keys = true botasaurus = Html2rss::RequestService::BotasaurusContract optional(:execution_mode).filled(:string, included_in?: botasaurus::EXECUTION_MODES) optional(:navigation_mode).filled(:string, included_in?: botasaurus::NAVIGATION_MODES) optional(:max_retries).filled(:integer, gteq?: 0, lteq?: botasaurus::MAX_RETRIES) optional(:wait_for_selector).maybe(:string) optional(:wait_timeout_seconds).filled( :integer, gteq?: botasaurus::MIN_WAIT_TIMEOUT_SECONDS, lteq?: botasaurus::MAX_WAIT_TIMEOUT_SECONDS ) optional(:scroll).filled(:bool) optional(:block_images).filled(:bool) optional(:block_images_and_css).filled(:bool) optional(:block_trackers).filled(:bool) optional(:wait_for_complete_page_load).filled(:bool) optional(:headless).filled(:bool) optional(:proxy).filled(:string) optional(:user_agent).filled(:string) optional(:window_size).hash do botasaurus::WINDOW_SIZE_PROPERTIES.each do |key| required(key).filled(:integer, gt?: 0) end end optional(:lang).filled(:string) optional(:cookies).hash optional(:headers).hash end
- RequestConfig =
Contract for the top-level
requestsection. Dry::Schema.Params do optional(:max_redirects).filled(:integer, gteq?: 0) optional(:max_requests).filled(:integer, gt?: 0) optional(:total_timeout_seconds).filled(:integer, gt?: 0) optional(:botasaurus).hash optional(:local_file_path).filled(:string) end