Merge pull request #3402 from wing328/ruby_fix_minlength

[Ruby] Fix minLength, maxLength
This commit is contained in:
wing328 2016-07-19 15:58:51 +08:00 committed by GitHub
commit 207622a8f8
3 changed files with 9 additions and 9 deletions

View File

@ -56,18 +56,18 @@ module {{moduleName}}
{{/isEnum}} {{/isEnum}}
{{/required}} {{/required}}
{{#hasValidation}} {{#hasValidation}}
{{#minLength}} {{#maxLength}}
if {{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}}.to_s.length > {{{maxLength}}} if {{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}}.to_s.length > {{{maxLength}}}
fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, the character length must be smaller than or equal to {{{maxLength}}}.' fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, the character length must be smaller than or equal to {{{maxLength}}}.'
end end
{{/minLength}} {{/maxLength}}
{{#maxLength}} {{#minLength}}
if {{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}}.to_s.length < {{{minLength}}} if {{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}}.to_s.length < {{{minLength}}}
fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, the character length must be great than or equal to {{{minLength}}}.' fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, the character length must be great than or equal to {{{minLength}}}.'
end end
{{/maxLength}} {{/minLength}}
{{#maximum}} {{#maximum}}
if {{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}} > {{{maximum}}} if {{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}} > {{{maximum}}}
fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{{maximum}}}.' fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{{maximum}}}.'

View File

@ -82,18 +82,18 @@
fail ArgumentError, "{{{name}}} cannot be nil" fail ArgumentError, "{{{name}}} cannot be nil"
end end
{{#minLength}} {{#maxLength}}
if @{{{name}}}.to_s.length > {{{maxLength}}} if @{{{name}}}.to_s.length > {{{maxLength}}}
invalid_properties.push("invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}.") invalid_properties.push("invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}.")
end end
{{/minLength}} {{/maxLength}}
{{#maxLength}} {{#minLength}}
if @{{{name}}}.to_s.length < {{{minLength}}} if @{{{name}}}.to_s.length < {{{minLength}}}
invalid_properties.push("invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}.") invalid_properties.push("invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}.")
end end
{{/maxLength}} {{/minLength}}
{{#maximum}} {{#maximum}}
if @{{{name}}} > {{{maximum}}} if @{{{name}}} > {{{maximum}}}
invalid_properties.push("invalid value for '{{{name}}}', must be smaller than or equal to {{{maximum}}}.") invalid_properties.push("invalid value for '{{{name}}}', must be smaller than or equal to {{{maximum}}}.")

View File

@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/
- API version: 1.0.0 - API version: 1.0.0
- Package version: 1.0.0 - Package version: 1.0.0
- Build date: 2016-07-14T16:12:28.313+08:00 - Build date: 2016-07-19T15:06:57.795+08:00
- Build package: class io.swagger.codegen.languages.RubyClientCodegen - Build package: class io.swagger.codegen.languages.RubyClientCodegen
## Installation ## Installation