Class: Schemacop::V2::StringValidator
- Defined in:
- lib/schemacop/v2/validator/string_validator.rb
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ StringValidator
constructor
A new instance of StringValidator.
- #validate(data, collector) ⇒ Object
Methods inherited from Node
build, class_matches?, clear_klasses, clear_symbols, #exec_block, klass, option, #option, #option?, register, #resolve_type_klass, symbol, symbol_matches?, #type_filter_matches?, #type_label, type_matches?, #type_matches?
Constructor Details
#initialize(options = {}) ⇒ StringValidator
Returns a new instance of StringValidator.
9 10 11 12 13 |
# File 'lib/schemacop/v2/validator/string_validator.rb', line 9 def initialize( = {}) super() end |
Instance Method Details
#validate(data, collector) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/schemacop/v2/validator/string_validator.rb', line 15 def validate(data, collector) super if option?(:min) && data.size < option(:min) collector.error "String must be longer (>=) than #{option(:min)} characters." end if option?(:max) && data.size > option(:max) collector.error "String must be shorter (<=) than #{option(:max)} characters." end end |