|
94 | 94 |
|
95 | 95 | {{/required}} |
96 | 96 | {{#hasValidation}} |
97 | | - {{#maximum}} |
98 | | - if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{{maximum}}} |
99 | | - invalid_properties.push('invalid value for "{{{name}}}", must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{{maximum}}}.') |
100 | | - end |
101 | | - |
102 | | - {{/maximum}} |
103 | | - {{#minimum}} |
104 | | - if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{{minimum}}} |
105 | | - invalid_properties.push('invalid value for "{{{name}}}", must be greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{{minimum}}}.') |
106 | | - end |
107 | | - |
108 | | - {{/minimum}} |
109 | 97 | {{#pattern}} |
110 | 98 | #if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} !~ Regexp.new({{{pattern}}}) |
111 | 99 | #invalid_properties.push('invalid value for "{{{name}}}", must conform to the pattern {{{pattern}}}.') |
112 | 100 | #end |
113 | 101 |
|
114 | 102 | {{/pattern}} |
115 | | - {{#maxItems}} |
116 | | - if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.length > {{{maxItems}}} |
117 | | - invalid_properties.push('invalid value for "{{{name}}}", number of items must be less than or equal to {{{maxItems}}}.' |
118 | | - end |
119 | | - |
120 | | - {{/maxItems}} |
121 | | - {{#minItems}} |
122 | | - if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.length < {{{minItems}}} |
123 | | - invalid_properties.push('invalid value for "{{{name}}}", number of items must be greater than or equal to {{{minItems}}}.' |
124 | | - end |
125 | | - |
126 | | - {{/minItems}} |
127 | 103 | {{/hasValidation}} |
128 | 104 | {{/vars}} |
129 | 105 | invalid_properties |
|
143 | 119 | {{/isContainer}} |
144 | 120 | {{/isEnum}} |
145 | 121 | {{#hasValidation}} |
146 | | - {{#maximum}} |
147 | | - return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{{maximum}}} |
148 | | - {{/maximum}} |
149 | | - {{#minimum}} |
150 | | - return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{{minimum}}} |
151 | | - {{/minimum}} |
152 | 122 | {{#pattern}} |
153 | 123 | #return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} !~ Regexp.new({{{pattern}}}) |
154 | 124 | {{/pattern}} |
155 | | - {{#maxItems}} |
156 | | - return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.length > {{{maxItems}}} |
157 | | - {{/maxItems}} |
158 | | - {{#minItems}} |
159 | | - return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.length < {{{minItems}}} |
160 | | - {{/minItems}} |
161 | 125 | {{/hasValidation}} |
162 | 126 | {{/vars}} |
163 | 127 | true |
|
189 | 153 | end |
190 | 154 |
|
191 | 155 | {{/required}} |
192 | | - {{#maximum}} |
193 | | - if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{{maximum}}} |
194 | | - fail ArgumentError, 'invalid value for "{{{name}}}", must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{{maximum}}}.' |
195 | | - end |
196 | | - |
197 | | - {{/maximum}} |
198 | | - {{#minimum}} |
199 | | - if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{{minimum}}} |
200 | | - fail ArgumentError, 'invalid value for "{{{name}}}", must be greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{{minimum}}}.' |
201 | | - end |
202 | | - |
203 | | - {{/minimum}} |
204 | 156 | {{#pattern}} |
205 | 157 | #if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}} !~ Regexp.new({{{pattern}}}) |
206 | 158 | #fail ArgumentError, 'invalid value for "{{{name}}}", must conform to the pattern {{{pattern}}}.' |
207 | 159 | #end |
208 | 160 |
|
209 | 161 | {{/pattern}} |
210 | | - {{#maxItems}} |
211 | | - if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.length > {{{maxItems}}} |
212 | | - fail ArgumentError, 'invalid value for "{{{name}}}", number of items must be less than or equal to {{{maxItems}}}.' |
213 | | - end |
214 | | - |
215 | | - {{/maxItems}} |
216 | | - {{#minItems}} |
217 | | - if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.length < {{{minItems}}} |
218 | | - fail ArgumentError, 'invalid value for "{{{name}}}", number of items must be greater than or equal to {{{minItems}}}.' |
219 | | - end |
220 | | - |
221 | | - {{/minItems}} |
222 | 162 | @{{{name}}} = {{{name}}} |
223 | 163 | end |
224 | 164 |
|
|
0 commit comments