public function populate($value) : void
    {
        $isArray = $this->isArray();

        if ($value === null) {
            $value = $isArray ? [] : '';
        } else {
            $isCorrectType = $isArray ? is_array($value) : is_string($value);

            if (! $isCorrectType) {
                throw new \InvalidArgumentException(sprintf(
                    'Invalid value received for "%s": expected %s, got %s',
                    $this->getName(),
                    $isArray ? 'array' : 'string',
                    gettype($value)
                ));
            }
        }

        $this->resetErrors();

        $empty = ($value === '' || $value === []);

        if ($empty && $this->required) {
            $this->addTranslatableError('form.required', 'This field is required.');
        }

        if (! $empty && ! $isArray) {
            $value = $this->filter($value);
            $this->validate($value);
        }

        $this->doPopulate($value);
    }