Class: LogStash::PluginMixins::ValidatorSupport::NamedValidationInterceptor Private
- Inherits:
-
Module
- Object
- Module
- LogStash::PluginMixins::ValidatorSupport::NamedValidationInterceptor
- Defined in:
- lib/logstash/plugin_mixins/validator_support.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A NamedValidationInterceptor intercepts requests to validate input with the given name and instead substitutes its own implementation. This implementation will override Logstash core functionality.
Instance Method Summary collapse
-
#initialize(validator_name, validator) ⇒ NamedValidationInterceptor
constructor
private
A new instance of NamedValidationInterceptor.
Constructor Details
#initialize(validator_name, validator) ⇒ NamedValidationInterceptor
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.
Returns a new instance of NamedValidationInterceptor.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/logstash/plugin_mixins/validator_support.rb', line 68 def initialize(validator_name, validator) fail(ArgumentError, '`validator_name` must be a Symbol') unless validator_name.kind_of?(Symbol) fail(ArgumentError, '`validator` must respond to `\#{validate}`') unless validator.respond_to?(:validate) define_method(:validate_value) do |value, required_validator| if required_validator != validator_name super(value, required_validator) else value = deep_replace(value) value = hash_or_array(value) validator.validate(value) end end define_singleton_method(:name) { "#{NamedValidationInterceptor}(#{validator_name})" } end |