Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v1.0.0
# 1.0.2

- Fix: '' value behavior in `field_reference` validator [#2](https://github.com/logstash-plugins/logstash-mixin-validator_support/pull/2)

# 1.0.1

- Introduces plugin parameter validation adapters, including initial backport for `:field_reference` validator.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ module ValidatorSupport

FieldReferenceValidationAdapter = NamedValidationAdapter.new(:field_reference) do |value|
break ValidationResult.failure("Expected exactly one field reference, got `#{value.inspect}`") unless value.kind_of?(Array) && value.size <= 1
break ValidationResult.success(nil) if value.empty? || value.first.nil?

candidate = value.first

break ValidationResult.success(nil) if value.empty? || candidate.nil? || candidate.empty?

break ValidationResult.failure("Expected a valid field reference, got `#{candidate.inspect}`") unless field_reference_pattern =~ candidate

break ValidationResult.success(candidate)
Expand Down
2 changes: 1 addition & 1 deletion logstash-mixin-validator_support.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'logstash-mixin-validator_support'
s.version = '1.0.1'
s.version = '1.0.2'
s.licenses = %w(Apache-2.0)
s.summary = "Support for the plugin parameter validations introduced in recent releases of Logstash, for plugins wishing to use them on older Logstashes"
s.description = "This gem is meant to be a dependency of any Logstash plugin that wishes to use validators introduced in recent versions of Logstash while maintaining backward-compatibility with earlier Logstashes. When used on older Logstash versions, it provides back-ports of the new validators."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@
end
end

context "valid input `''`" do
# failed in version 1.0.x which was not compatible with LS 7.x behavior
it 'correctly reports the value as valid' do
is_valid_result, coerced_or_error = described_class.validate ['']

expect(is_valid_result).to be true
expect(coerced_or_error).to be nil
end
end

[
['link[0]'],
['][N\\//\\L][D'],
Expand Down