Class: AllowedIframesValidator
- Inherits:
-
Object
- Object
- AllowedIframesValidator
- Defined in:
- lib/validators/allowed_iframes_validator.rb
Constant Summary collapse
- VALID_ALLOWED_IFRAME_URL_REGEX =
Url starts with http:// or https:// and has at least one more additional ‘/’
%r{\Ahttps?://([^/]*/)+[^/]*\z}x
Instance Method Summary collapse
- #error_message ⇒ Object
-
#initialize(opts = {}) ⇒ AllowedIframesValidator
constructor
A new instance of AllowedIframesValidator.
- #valid_value?(values) ⇒ Boolean
Constructor Details
#initialize(opts = {}) ⇒ AllowedIframesValidator
Returns a new instance of AllowedIframesValidator.
7 8 9 |
# File 'lib/validators/allowed_iframes_validator.rb', line 7 def initialize(opts = {}) @opts = opts end |
Instance Method Details
#error_message ⇒ Object
15 16 17 |
# File 'lib/validators/allowed_iframes_validator.rb', line 15 def I18n.t("site_settings.errors.invalid_allowed_iframes_url") end |
#valid_value?(values) ⇒ Boolean
11 12 13 |
# File 'lib/validators/allowed_iframes_validator.rb', line 11 def valid_value?(values) values.split("|").all? { _1.match? VALID_ALLOWED_IFRAME_URL_REGEX } end |