Class: SearchRankingWeightsValidator
- Inherits:
-
Object
- Object
- SearchRankingWeightsValidator
- Defined in:
- lib/validators/search_ranking_weights_validator.rb
Constant Summary collapse
- WEIGHT_REGEXP =
"1\.0|0\.[0-9]+"
- WEIGHTS_REGEXP =
/{(?<d_weight>#{WEIGHT_REGEXP}),(?<c_weight>#{WEIGHT_REGEXP}),(?<b_weight>#{WEIGHT_REGEXP}),(?<a_weight>#{WEIGHT_REGEXP})}/
Instance Method Summary collapse
- #error_message ⇒ Object
-
#initialize(opts = {}) ⇒ SearchRankingWeightsValidator
constructor
A new instance of SearchRankingWeightsValidator.
- #valid_value?(value) ⇒ Boolean
Constructor Details
#initialize(opts = {}) ⇒ SearchRankingWeightsValidator
Returns a new instance of SearchRankingWeightsValidator.
4 5 6 |
# File 'lib/validators/search_ranking_weights_validator.rb', line 4 def initialize(opts = {}) @opts = opts end |
Instance Method Details
#error_message ⇒ Object
17 18 19 |
# File 'lib/validators/search_ranking_weights_validator.rb', line 17 def I18n.t("site_settings.errors.invalid_search_ranking_weights") end |
#valid_value?(value) ⇒ Boolean
12 13 14 15 |
# File 'lib/validators/search_ranking_weights_validator.rb', line 12 def valid_value?(value) return true if value.blank? value.match(WEIGHTS_REGEXP) end |