public function getError()
    {
        $error = new Error($this->getMessage());
        $error->setValue($this->value);
        if ($this->field !== null) {
            $error->setName($this->field->getName());
        }
        if ($this->valueIndex !== null) {
            $error->setIndex($this->valueIndex);
        }
        return $error;
    }