@@ -274,8 +274,8 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}}{{/parentSchema}}{{^par
274274
275275 { {#vars} }
276276 { {#required} }
277- if ($this->container['{ {name} }'] === null) {
278- $invalidProperties [] = " '{{name}}' can't be null" ;
277+ if ($this->container['{ {name} }'] === null{ {#isNullable } } && !$this->isNullableSetToNull(' { {name } }') { {/isNullable } } ) {
278+ $invalidProperties [] = " '{{name}}' {{^isNullable}} can't be null" {{/isNullable } } { {#isNullable } }is required" { {/isNullable } } ;
279279 }
280280 { {/required} }
281281 { {#isEnum} }
@@ -293,43 +293,43 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}}{{/parentSchema}}{{^par
293293 { {/isEnum} }
294294 { {#hasValidation} }
295295 { {#maxLength} }
296- if ({ {^required } }!is_null($this->container['{ {name} }']) && { {/required } }(mb_strlen($this->container['{ {name} }']) > { {maxLength} })) {
296+ if ({ {#notRequiredOrIsNullable } }!is_null($this->container['{ {name} }']) && { {/notRequiredOrIsNullable } }(mb_strlen($this->container['{ {name} }']) > { {maxLength} })) {
297297 $invalidProperties [] = " invalid value for '{{name}}', the character length must be smaller than or equal to {{{maxLength}}}." ;
298298 }
299299
300300 { {/maxLength} }
301301 { {#minLength} }
302- if ({ {^required } }!is_null($this->container['{ {name} }']) && { {/required } }(mb_strlen($this->container['{ {name} }']) < { {minLength} })) {
302+ if ({ {#notRequiredOrIsNullable } }!is_null($this->container['{ {name} }']) && { {/notRequiredOrIsNullable } }(mb_strlen($this->container['{ {name} }']) < { {minLength} })) {
303303 $invalidProperties [] = " invalid value for '{{name}}', the character length must be bigger than or equal to {{{minLength}}}." ;
304304 }
305305
306306 { {/minLength} }
307307 { {#maximum} }
308- if ({ {^required } }!is_null($this->container['{ {name} }']) && { {/required } }($this->container['{ {name} }'] >{ {#exclusiveMaximum} }={ {/exclusiveMaximum} } { {maximum} })) {
308+ if ({ {#notRequiredOrIsNullable } }!is_null($this->container['{ {name} }']) && { {/notRequiredOrIsNullable } }($this->container['{ {name} }'] >{ {#exclusiveMaximum} }={ {/exclusiveMaximum} } { {maximum} })) {
309309 $invalidProperties [] = " invalid value for '{{name}}', must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{maximum}}." ;
310310 }
311311
312312 { {/maximum} }
313313 { {#minimum} }
314- if ({ {^required } }!is_null($this->container['{ {name} }']) && { {/required } }($this->container['{ {name} }'] <{ {#exclusiveMinimum} }={ {/exclusiveMinimum} } { {minimum} })) {
314+ if ({ {#notRequiredOrIsNullable } }!is_null($this->container['{ {name} }']) && { {/notRequiredOrIsNullable } }($this->container['{ {name} }'] <{ {#exclusiveMinimum} }={ {/exclusiveMinimum} } { {minimum} })) {
315315 $invalidProperties [] = " invalid value for '{{name}}', must be bigger than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{minimum}}." ;
316316 }
317317
318318 { {/minimum} }
319319 { {#pattern} }
320- if ({ {^required } }!is_null($this->container['{ {name} }']) && { {/required } }!preg_match("{ {{pattern} }}", $this->container['{ {name} }'])) {
320+ if ({ {#notRequiredOrIsNullable } }!is_null($this->container['{ {name} }']) && { {/notRequiredOrIsNullable } }!preg_match("{ {{pattern} }}", $this->container['{ {name} }'])) {
321321 $invalidProperties [] = " invalid value for '{{name}}', must be conform to the pattern {{{pattern}}}." ;
322322 }
323323
324324 { {/pattern} }
325325 { {#maxItems} }
326- if ({ {^required } }!is_null($this->container['{ {name} }']) && { {/required } }(count($this->container['{ {name} }']) > { {maxItems} })) {
326+ if ({ {#notRequiredOrIsNullable } }!is_null($this->container['{ {name} }']) && { {/notRequiredOrIsNullable } }(count($this->container['{ {name} }']) > { {maxItems} })) {
327327 $invalidProperties [] = " invalid value for '{{name}}', number of items must be less than or equal to {{{maxItems}}}." ;
328328 }
329329
330330 { {/maxItems} }
331331 { {#minItems} }
332- if ({ {^required } }!is_null($this->container['{ {name} }']) && { {/required } }(count($this->container['{ {name} }']) < { {minItems} })) {
332+ if ({ {#notRequiredOrIsNullable } }!is_null($this->container['{ {name} }']) && { {/notRequiredOrIsNullable } }(count($this->container['{ {name} }']) < { {minItems} })) {
333333 $invalidProperties [] = " invalid value for '{{name}}', number of items must be greater than or equal to {{{minItems}}}." ;
334334 }
335335
0 commit comments