Module: Mihari::Concerns::FalsePositiveValidatable
- Extended by:
- ActiveSupport::Concern
- Includes:
- MemoWise
- Included in:
- Rule, Schemas::RuleContract
- Defined in:
- lib/mihari/concerns/falsepositive_validatable.rb
Overview
False positive validatable concern
Instance Method Summary collapse
-
#normalize_falsepositive(value) ⇒ String, Regexp
Normalize a falsepositive value.
-
#valid_falsepositive?(value) ⇒ Boolean
Check whether a value is valid format as a disallowed data value.
Instance Method Details
#normalize_falsepositive(value) ⇒ String, Regexp
Normalize a falsepositive value
20 21 22 23 24 25 26 |
# File 'lib/mihari/concerns/falsepositive_validatable.rb', line 20 def normalize_falsepositive(value) return value if !value.start_with?("/") || !value.end_with?("/") # if a value is surrounded by slashes, take it as a regexp value_without_slashes = value[1..-2] Regexp.compile value_without_slashes.to_s end |
#valid_falsepositive?(value) ⇒ Boolean
Check whether a value is valid format as a disallowed data value
36 37 38 39 40 41 42 43 |
# File 'lib/mihari/concerns/falsepositive_validatable.rb', line 36 def valid_falsepositive?(value) begin normalize_falsepositive value rescue RegexpError return false end true end |