protected function getAttributeFilter()
    {
        if ($this->attributeFilter) {
            return $this->attributeFilter;
        }

        return function ($key, $value) {
            if (in_array($key, $this->getNonScalarAttributes())) {
                return !is_scalar($value);
            }

            if (ends_with($key, '_id') && trim($value) === '') {
                return false;
            }

            return is_scalar($value) || $value instanceof DateTime;
        };
    }