Skip to content

Commit

Permalink
[Bug]: Fix QuantityRangeValue validation failed on empty field (pimco…
Browse files Browse the repository at this point in the history
…re#17743)

* Update QuantityValueRange.php

* refactor

* Apply php-cs-fixer changes

---------

Co-authored-by: kingjia90 <[email protected]>
  • Loading branch information
kingjia90 and kingjia90 authored Oct 21, 2024
1 parent c9984f9 commit 5046f03
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions models/DataObject/ClassDefinition/Data/QuantityValueRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,19 +286,20 @@ public function checkValidity(mixed $data, bool $omitMandatoryCheck = false, arr
throw new ValidationException('Expected an instance of QuantityValueRange');
}

$minimum = $data->getMinimum();
$maximum = $data->getMaximum();

if ($omitMandatoryCheck === false && $this->getMandatory()
&& ($data === null
|| $data->getMinimum() === null
|| $data->getMaximum() === null
|| $minimum === null
|| $maximum === null
|| $data->getUnitId() === null
)
) {
throw new ValidationException(sprintf('Empty mandatory field [ %s ]', $fieldName));
}

if (!empty($data)) {
$minimum = $data->getMinimum();
$maximum = $data->getMaximum();
if ($minimum || $maximum) {

if (!is_numeric($minimum) || !is_numeric($maximum)) {
throw new ValidationException(sprintf('Invalid dimension unit data: %s', $fieldName));
Expand Down

0 comments on commit 5046f03

Please sign in to comment.