Class: JSONSchemer::Fuzz::Keyword::MaxLength

Inherits:
Object
  • Object
show all
Defined in:
lib/json_schemer/fuzz/keyword/max_length.rb

Class Method Summary collapse

Class Method Details

.invalid_params(attributes) ⇒ Object

Returns Array.

Returns:

  • Array



7
8
9
10
11
12
13
14
15
16
# File 'lib/json_schemer/fuzz/keyword/max_length.rb', line 7

def invalid_params(attributes)
  max_length = attributes["maxLength"]
  raise "No maxLength keyword given: #{attributes}" unless max_length

  generated_params = []

  generated_params << /\w{1}/.gen * (max_length + 1)

  generated_params
end

.valid_param(attributes) ⇒ Object



18
19
20
21
22
23
# File 'lib/json_schemer/fuzz/keyword/max_length.rb', line 18

def valid_param(attributes)
  max_length = attributes["maxLength"]
  raise "No maxLength keyword given: #{attributes}" unless max_length

  /\w{1}/.gen * max_length
end