diff --git a/src/Attributes/DataBindings/Json/JsonArray.php b/src/Attributes/DataBindings/Json/JsonArray.php index 4d42ee0..6891f2e 100644 --- a/src/Attributes/DataBindings/Json/JsonArray.php +++ b/src/Attributes/DataBindings/Json/JsonArray.php @@ -32,7 +32,7 @@ public function buildProperty(object $instance, ReflectionProperty $property, mi { $key = (empty($this->alias)) ? $property->getName() : $this->alias; - if ($this->required && empty($jsonValue->{$key})) { + if ($this->required && !isset($jsonValue->{$key})) { $className = get_class($instance); throw new InvalidParameterTypeException( "JS001", diff --git a/src/Attributes/DataBindings/Json/JsonProperty.php b/src/Attributes/DataBindings/Json/JsonProperty.php index 3e83616..abb7eaf 100644 --- a/src/Attributes/DataBindings/Json/JsonProperty.php +++ b/src/Attributes/DataBindings/Json/JsonProperty.php @@ -30,7 +30,7 @@ public function buildProperty(object $instance, ReflectionProperty $property, mi { $key = (empty($this->alias)) ? $property->getName() : $this->alias; - if ($this->required && empty($jsonValue->{$key})) { + if ($this->required && !isset($jsonValue->{$key})) { $className = get_class($instance); throw new InvalidParameterTypeException( "JS001",