Class: InputSanitizer::CommaJoinedStringsConverter
- Inherits:
-
Object
- Object
- InputSanitizer::CommaJoinedStringsConverter
- Defined in:
- lib/input_sanitizer/extended_converters/comma_joined_strings_converter.rb
Instance Method Summary collapse
Instance Method Details
#call(value) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/input_sanitizer/extended_converters/comma_joined_strings_converter.rb', line 3 def call(value) value = value.to_s non_valid = value.gsub(/[a-zA-Z,_]/, "") if non_valid.empty? value.split(",").map(&:to_s) else invalid_chars = non_valid.split(//).join(", ") raise InputSanitizer::ConversionError.new("Invalid strings: #{invalid_chars}") end end |