protected function validatePermissionsUserRole()
    {
        $field = 'permissions';

        if ($this->isExcluded($field)) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if ($this->isUpdating() && !isset($value)) {
            $this->unsetSubmitted($field);
            return null;
        }

        if (empty($value)) {
            $this->setSubmitted($field, array());
            return null;
        }

        if (!is_array($value)) {
            $this->setErrorInvalid($field, $this->translation->text('Permissions'));
            return false;
        }

        $permissions = $this->role->getPermissions();
        $invalid = array_diff($value, array_keys($permissions));

        if (!empty($invalid)) {
            $this->setErrorUnavailable($field, implode(',', $invalid));
            return false;
        }

        return true;
    }