Class: Kharon::Processors::TextProcessor
- Inherits:
-
Kharon::Processor
- Object
- Kharon::Processor
- Kharon::Processors::TextProcessor
- Defined in:
- lib/kharon/processors/text_processor.rb
Overview
Processor to validate simple strings. It has the :regex option plus the default ones.
Instance Attribute Summary
Attributes inherited from Kharon::Processor
Instance Method Summary (collapse)
-
- (Object) process(key, options = {})
Checks if the given key is a not-empty string or not.
-
- (Object) store(key, process, options)
Stores a string after verifying that it respects a regular expression given in parameter.
Methods inherited from Kharon::Processor
Constructor Details
This class inherits a constructor from Kharon::Processor
Instance Method Details
- (Object) process(key, options = {})
Checks if the given key is a not-empty string or not.
15 16 17 18 |
# File 'lib/kharon/processors/text_processor.rb', line 15 def process(key, = {}) before_all(key, ) is_typed?(key, String) ? store(key, ->(item){item.to_s}, ) : raise_type_error(key, "String") end |
- (Object) store(key, process, options)
Stores a string after verifying that it respects a regular expression given in parameter.
24 25 26 27 |
# File 'lib/kharon/processors/text_processor.rb', line 24 def store(key, process, ) match_regex?(key, validator.datas[key], [:regex]) if(.has_key?(:regex)) super(key, process, ) end |