public function setValue($value, $persist = true)
    {
        if ($this->isEmpty($value) && ! $this->flags & Value::CAN_BE_EMPTY) {
            throw FailedToValidate::fromValue($value, $this);
        }

        if (! $this->isEmpty($value)) {
            $value = $this->validate($value);
        }

        if (null === $value) {
            throw FailedToValidate::fromValue($value, $this);
        }

        $this->value = $value;

        if (! $persist ) {
            return $this;
        }

        $repository  = IdentityMap::getInstance()->getRepository($this->key);
        $repository->save($this);

        return $this;
    }