Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ module {{moduleName}}

{{/minimum}}
{{#pattern}}
if @api_client.config.client_side_validation && {{^required}}!opts[:'{{{paramName}}}'].nil? && {{/required}}{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}} !~ Regexp.new({{{pattern}}})
fail ArgumentError, "invalid value for '{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:\"{{{paramName}}}\"]{{/required}}' when calling {{classname}}.{{operationId}}, must conform to the pattern {{{pattern}}}."
pattern = Regexp.new({{{pattern}}})
if @api_client.config.client_side_validation && {{^required}}!opts[:'{{{paramName}}}'].nil? && {{/required}}{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}} !~ pattern
fail ArgumentError, "invalid value for '{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:\"{{{paramName}}}\"]{{/required}}' when calling {{classname}}.{{operationId}}, must conform to the pattern #{pattern}."
end

{{/pattern}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,9 @@

{{/minimum}}
{{#pattern}}
if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} !~ Regexp.new({{{pattern}}})
invalid_properties.push('invalid value for "{{{name}}}", must conform to the pattern {{{pattern}}}.')
pattern = Regexp.new({{{pattern}}})
if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} !~ pattern
invalid_properties.push("invalid value for \"{{{name}}}\", must conform to the pattern #{pattern}.")
end

{{/pattern}}
Expand Down Expand Up @@ -327,8 +328,9 @@

{{/minimum}}
{{#pattern}}
if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}} !~ Regexp.new({{{pattern}}})
fail ArgumentError, 'invalid value for "{{{name}}}", must conform to the pattern {{{pattern}}}.'
pattern = Regexp.new({{{pattern}}})
if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}} !~ pattern
fail ArgumentError, "invalid value for \"{{{name}}}\", must conform to the pattern #{pattern}."
end

{{/pattern}}
Expand Down
10 changes: 6 additions & 4 deletions samples/client/petstore/ruby/lib/petstore/api/fake_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,9 @@ def test_endpoint_parameters_with_http_info(number, double, pattern_without_deli
if @api_client.config.client_side_validation && pattern_without_delimiter.nil?
fail ArgumentError, "Missing the required parameter 'pattern_without_delimiter' when calling FakeApi.test_endpoint_parameters"
end
if @api_client.config.client_side_validation && pattern_without_delimiter !~ Regexp.new(/^[A-Z].*/)
fail ArgumentError, "invalid value for 'pattern_without_delimiter' when calling FakeApi.test_endpoint_parameters, must conform to the pattern /^[A-Z].*/."
pattern = Regexp.new(/^[A-Z].*/)
if @api_client.config.client_side_validation && pattern_without_delimiter !~ pattern
fail ArgumentError, "invalid value for 'pattern_without_delimiter' when calling FakeApi.test_endpoint_parameters, must conform to the pattern #{pattern}."
end

# verify the required parameter 'byte' is set
Expand All @@ -520,8 +521,9 @@ def test_endpoint_parameters_with_http_info(number, double, pattern_without_deli
fail ArgumentError, 'invalid value for "opts[:"float"]" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 987.6.'
end

if @api_client.config.client_side_validation && !opts[:'string'].nil? && opts[:'string'] !~ Regexp.new(/[a-z]/i)
fail ArgumentError, "invalid value for 'opts[:\"string\"]' when calling FakeApi.test_endpoint_parameters, must conform to the pattern /[a-z]/i."
pattern = Regexp.new(/[a-z]/i)
if @api_client.config.client_side_validation && !opts[:'string'].nil? && opts[:'string'] !~ pattern
fail ArgumentError, "invalid value for 'opts[:\"string\"]' when calling FakeApi.test_endpoint_parameters, must conform to the pattern #{pattern}."
end

if @api_client.config.client_side_validation && !opts[:'password'].nil? && opts[:'password'].to_s.length > 64
Expand Down
20 changes: 12 additions & 8 deletions samples/client/petstore/ruby/lib/petstore/models/format_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,18 @@ def list_invalid_properties
invalid_properties.push('invalid value for "double", must be greater than or equal to 67.8.')
end

if [email protected]? && @string !~ Regexp.new(/[a-z]/i)
invalid_properties.push('invalid value for "string", must conform to the pattern /[a-z]/i.')
pattern = Regexp.new(/[a-z]/i)
if [email protected]? && @string !~ pattern
invalid_properties.push("invalid value for \"string\", must conform to the pattern #{pattern}.")
end

if @byte.nil?
invalid_properties.push('invalid value for "byte", byte cannot be nil.')
end

if @byte !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
invalid_properties.push('invalid value for "byte", must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.')
pattern = Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
if @byte !~ pattern
invalid_properties.push("invalid value for \"byte\", must conform to the pattern #{pattern}.")
end

if @date.nil?
Expand Down Expand Up @@ -319,8 +321,9 @@ def double=(double)
# Custom attribute writer method with validation
# @param [Object] string Value to be assigned
def string=(string)
if !string.nil? && string !~ Regexp.new(/[a-z]/i)
fail ArgumentError, 'invalid value for "string", must conform to the pattern /[a-z]/i.'
pattern = Regexp.new(/[a-z]/i)
if !string.nil? && string !~ pattern
fail ArgumentError, "invalid value for \"string\", must conform to the pattern #{pattern}."
end

@string = string
Expand All @@ -333,8 +336,9 @@ def byte=(byte)
fail ArgumentError, 'byte cannot be nil'
end

if byte !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
fail ArgumentError, 'invalid value for "byte", must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.'
pattern = Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
if byte !~ pattern
fail ArgumentError, "invalid value for \"byte\", must conform to the pattern #{pattern}."
end

@byte = byte
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,9 @@ def test_endpoint_parameters_with_http_info(number, double, pattern_without_deli
if @api_client.config.client_side_validation && pattern_without_delimiter.nil?
fail ArgumentError, "Missing the required parameter 'pattern_without_delimiter' when calling FakeApi.test_endpoint_parameters"
end
if @api_client.config.client_side_validation && pattern_without_delimiter !~ Regexp.new(/^[A-Z].*/)
fail ArgumentError, "invalid value for 'pattern_without_delimiter' when calling FakeApi.test_endpoint_parameters, must conform to the pattern /^[A-Z].*/."
pattern = Regexp.new(/^[A-Z].*/)
if @api_client.config.client_side_validation && pattern_without_delimiter !~ pattern
fail ArgumentError, "invalid value for 'pattern_without_delimiter' when calling FakeApi.test_endpoint_parameters, must conform to the pattern #{pattern}."
end

# verify the required parameter 'byte' is set
Expand All @@ -476,8 +477,9 @@ def test_endpoint_parameters_with_http_info(number, double, pattern_without_deli
fail ArgumentError, 'invalid value for "opts[:"float"]" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 987.6.'
end

if @api_client.config.client_side_validation && !opts[:'string'].nil? && opts[:'string'] !~ Regexp.new(/[a-z]/i)
fail ArgumentError, "invalid value for 'opts[:\"string\"]' when calling FakeApi.test_endpoint_parameters, must conform to the pattern /[a-z]/i."
pattern = Regexp.new(/[a-z]/i)
if @api_client.config.client_side_validation && !opts[:'string'].nil? && opts[:'string'] !~ pattern
fail ArgumentError, "invalid value for 'opts[:\"string\"]' when calling FakeApi.test_endpoint_parameters, must conform to the pattern #{pattern}."
end

if @api_client.config.client_side_validation && !opts[:'password'].nil? && opts[:'password'].to_s.length > 64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,9 @@ def list_invalid_properties
invalid_properties.push('invalid value for "double", must be greater than or equal to 67.8.')
end

if [email protected]? && @string !~ Regexp.new(/[a-z]/i)
invalid_properties.push('invalid value for "string", must conform to the pattern /[a-z]/i.')
pattern = Regexp.new(/[a-z]/i)
if [email protected]? && @string !~ pattern
invalid_properties.push("invalid value for \"string\", must conform to the pattern #{pattern}.")
end

if @byte.nil?
Expand All @@ -229,12 +230,14 @@ def list_invalid_properties
invalid_properties.push('invalid value for "password", the character length must be great than or equal to 10.')
end

if !@pattern_with_digits.nil? && @pattern_with_digits !~ Regexp.new(/^\d{10}$/)
invalid_properties.push('invalid value for "pattern_with_digits", must conform to the pattern /^\d{10}$/.')
pattern = Regexp.new(/^\d{10}$/)
if !@pattern_with_digits.nil? && @pattern_with_digits !~ pattern
invalid_properties.push("invalid value for \"pattern_with_digits\", must conform to the pattern #{pattern}.")
end

if !@pattern_with_digits_and_delimiter.nil? && @pattern_with_digits_and_delimiter !~ Regexp.new(/^image_\d{1,3}$/i)
invalid_properties.push('invalid value for "pattern_with_digits_and_delimiter", must conform to the pattern /^image_\d{1,3}$/i.')
pattern = Regexp.new(/^image_\d{1,3}$/i)
if !@pattern_with_digits_and_delimiter.nil? && @pattern_with_digits_and_delimiter !~ pattern
invalid_properties.push("invalid value for \"pattern_with_digits_and_delimiter\", must conform to the pattern #{pattern}.")
end

invalid_properties
Expand Down Expand Up @@ -342,8 +345,9 @@ def double=(double)
# Custom attribute writer method with validation
# @param [Object] string Value to be assigned
def string=(string)
if !string.nil? && string !~ Regexp.new(/[a-z]/i)
fail ArgumentError, 'invalid value for "string", must conform to the pattern /[a-z]/i.'
pattern = Regexp.new(/[a-z]/i)
if !string.nil? && string !~ pattern
fail ArgumentError, "invalid value for \"string\", must conform to the pattern #{pattern}."
end

@string = string
Expand All @@ -370,8 +374,9 @@ def password=(password)
# Custom attribute writer method with validation
# @param [Object] pattern_with_digits Value to be assigned
def pattern_with_digits=(pattern_with_digits)
if !pattern_with_digits.nil? && pattern_with_digits !~ Regexp.new(/^\d{10}$/)
fail ArgumentError, 'invalid value for "pattern_with_digits", must conform to the pattern /^\d{10}$/.'
pattern = Regexp.new(/^\d{10}$/)
if !pattern_with_digits.nil? && pattern_with_digits !~ pattern
fail ArgumentError, "invalid value for \"pattern_with_digits\", must conform to the pattern #{pattern}."
end

@pattern_with_digits = pattern_with_digits
Expand All @@ -380,8 +385,9 @@ def pattern_with_digits=(pattern_with_digits)
# Custom attribute writer method with validation
# @param [Object] pattern_with_digits_and_delimiter Value to be assigned
def pattern_with_digits_and_delimiter=(pattern_with_digits_and_delimiter)
if !pattern_with_digits_and_delimiter.nil? && pattern_with_digits_and_delimiter !~ Regexp.new(/^image_\d{1,3}$/i)
fail ArgumentError, 'invalid value for "pattern_with_digits_and_delimiter", must conform to the pattern /^image_\d{1,3}$/i.'
pattern = Regexp.new(/^image_\d{1,3}$/i)
if !pattern_with_digits_and_delimiter.nil? && pattern_with_digits_and_delimiter !~ pattern
fail ArgumentError, "invalid value for \"pattern_with_digits_and_delimiter\", must conform to the pattern #{pattern}."
end

@pattern_with_digits_and_delimiter = pattern_with_digits_and_delimiter
Expand Down