|
99 | 99 | {{#vars}} |
100 | 100 | {{#hasValidation}} |
101 | 101 | {{#maxLength}} |
102 | | - if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.size > {{{maxLength}}} |
| 102 | + if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.try &.to_s.try &.size.try &.> {{{maxLength}}} |
103 | 103 | invalid_properties.push("invalid value for \"{{{name}}}\", the character length must be smaller than or equal to {{{maxLength}}}.") |
104 | 104 | end |
105 | 105 |
|
106 | 106 | {{/maxLength}} |
107 | 107 | {{#minLength}} |
108 | | - if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.size < {{{minLength}}} |
| 108 | + if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.try &.to_s.try &.size.try &.< {{{minLength}}} |
109 | 109 | invalid_properties.push("invalid value for \"{{{name}}}\", the character length must be greater than or equal to {{{minLength}}}.") |
110 | 110 | end |
111 | 111 |
|
112 | 112 | {{/minLength}} |
113 | 113 | {{#maximum}} |
114 | | - if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{{maximum}}} |
| 114 | + if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.try &.>{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{{maximum}}} |
115 | 115 | invalid_properties.push("invalid value for \"{{{name}}}\", must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{{maximum}}}.") |
116 | 116 | end |
117 | 117 |
|
118 | 118 | {{/maximum}} |
119 | 119 | {{#minimum}} |
120 | | - if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{{minimum}}} |
| 120 | + if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.try &.<{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{{minimum}}} |
121 | 121 | invalid_properties.push("invalid value for \"{{{name}}}\", must be greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{{minimum}}}.") |
122 | 122 | end |
123 | 123 |
|
124 | 124 | {{/minimum}} |
125 | 125 | {{#pattern}} |
126 | | - pattern = Regexp.new({{{pattern}}}) |
127 | | - if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} !~ pattern |
| 126 | + pattern = {{{pattern}}} |
| 127 | + if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.try &.!~ pattern |
128 | 128 | invalid_properties.push("invalid value for \"{{{name}}}\", must conform to the pattern #{pattern}.") |
129 | 129 | end |
130 | 130 |
|
131 | 131 | {{/pattern}} |
132 | 132 | {{#maxItems}} |
133 | | - if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.size > {{{maxItems}}} |
| 133 | + if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.try &.size.try &.> {{{maxItems}}} |
134 | 134 | invalid_properties.push("invalid value for \"{{{name}}}\", number of items must be less than or equal to {{{maxItems}}}." |
135 | 135 | end |
136 | 136 |
|
137 | 137 | {{/maxItems}} |
138 | 138 | {{#minItems}} |
139 | | - if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.size < {{{minItems}}} |
| 139 | + if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.try &.size.try &.< {{{minItems}}} |
140 | 140 | invalid_properties.push("invalid value for \"{{{name}}}\", number of items must be greater than or equal to {{{minItems}}}." |
141 | 141 | end |
142 | 142 |
|
|
158 | 158 | {{/isEnum}} |
159 | 159 | {{#hasValidation}} |
160 | 160 | {{#maxLength}} |
161 | | - return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.size > {{{maxLength}}} |
| 161 | + return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.try &.to_s.try &.size.try &.> {{{maxLength}}} |
162 | 162 | {{/maxLength}} |
163 | 163 | {{#minLength}} |
164 | | - return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.size < {{{minLength}}} |
| 164 | + return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.try &.to_s.try &.size.try &.< {{{minLength}}} |
165 | 165 | {{/minLength}} |
166 | 166 | {{#maximum}} |
167 | | - return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{{maximum}}} |
| 167 | + return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.try &.>{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{{maximum}}} |
168 | 168 | {{/maximum}} |
169 | 169 | {{#minimum}} |
170 | | - return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{{minimum}}} |
| 170 | + return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.try &.<{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{{minimum}}} |
171 | 171 | {{/minimum}} |
172 | 172 | {{#pattern}} |
173 | | - return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} !~ Regexp.new({{{pattern}}}) |
| 173 | + return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.try &.!~ {{{pattern}}} |
174 | 174 | {{/pattern}} |
175 | 175 | {{#maxItems}} |
176 | | - return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.size > {{{maxItems}}} |
| 176 | + return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.try &.size.try &.> {{{maxItems}}} |
177 | 177 | {{/maxItems}} |
178 | 178 | {{#minItems}} |
179 | | - return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.size < {{{minItems}}} |
| 179 | + return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.try &.size.try &.< {{{minItems}}} |
180 | 180 | {{/minItems}} |
181 | 181 | {{/hasValidation}} |
182 | 182 | {{/vars}} |
|
0 commit comments