diff --git a/src/Fabs/Serialize/Validation/ObjectValidation.php b/src/Fabs/Serialize/Validation/ObjectValidation.php index 06ebd2a..0ce5a09 100644 --- a/src/Fabs/Serialize/Validation/ObjectValidation.php +++ b/src/Fabs/Serialize/Validation/ObjectValidation.php @@ -13,6 +13,8 @@ class ObjectValidation extends ValidationBase { /** @var string */ protected $type = null; + /** @var string */ + protected $given = null; /** * @param $type string @@ -26,6 +28,16 @@ public function setType($type) public function isValid($value) { + if ($value === null) { + $this->given = null; + } else { + if (is_object($value)) { + $this->given = get_class($value); + } else { + $this->given = gettype($value); + } + } + if ($value === null) { if ($this->is_required) { return false; @@ -39,6 +51,7 @@ public function isValid($value) public function getValidationName() { - return $this->type; + return 'expected: ' . $this->type . ' given: ' . $this->given; } } +