Class: JsonStructure::String
Instance Method Summary collapse
- #===(value) ⇒ Object
-
#initialize(min_length: nil, max_length: nil, pattern: nil) ⇒ String
constructor
A new instance of String.
Methods inherited from Type
Constructor Details
#initialize(min_length: nil, max_length: nil, pattern: nil) ⇒ String
Returns a new instance of String.
3 4 5 6 7 |
# File 'lib/json_structure/string.rb', line 3 def initialize(min_length: nil, max_length: nil, pattern: nil) @min_length = min_length @max_length = max_length @pattern = pattern end |
Instance Method Details
#===(value) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/json_structure/string.rb', line 9 def ===(value) return false unless value.is_a?(::String) return false if @min_length && value.size < @min_length return false if @max_length && value.size > @max_length return false if @pattern && @pattern !~ value true end |