Check for group existence
@function $os~groupExists
@param {string|number} group - Groupname or group id
@returns {boolean} - Whether the group exists or not
@example
// Check if group 'mysql' exists
$os.groupExists('mysql');
// => true
518518
function groupExists(group) {
  if (isPlatform('windows')) {
    throw new Error('Don\'t know how to check for group existence on Windows');
  } else {
    if (_.isEmpty(findGroup(group, {refresh: true, throwIfNotFound: false}))) {
      return false;
    } else {
      return true;
    }
  }
}
730561
protected boolean existsMembership(String userId, String groupId) {
    Map<String, String> key = new HashMap<>();
    key.put("userId", userId);
    key.put("groupId", groupId);
    return ((Long) getDbEntityManager().selectOne("selectMembershipCount", key)) > 0;
  }
266475
def group_exists(groupname):
    """"""
    try:
        grp.getgrnam(groupname)
        group_exists = True
    except KeyError:
        group_exists = False
    return group_exists
554174
private boolean checkIfKeyExists(String key)
    {
        if (aggregationsKeySet == null)
        {
            aggregationsKeySet = new HashSet<String>();
        }
        return aggregationsKeySet.add(key);
    }
526097
def option_group_exists(name, tags=None, region=None, key=None, keyid=None,
                        profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    try:
        rds = conn.describe_option_groups(OptionGroupName=name)
        return {'exists': bool(rds)}
    except ClientError as e:
        return {'error': __utils__['boto3.get_error'](e)}
939190
public function hasGroup($group)
    {
        if (is_string($group)) {
            return $this->groups->contains('name', $group);
        }

        return ! ! $group->intersect($this->groups)->count();
    }
679529
public function groupExists($groupDn = null, $userGuid = false) {
		if (empty($groupDn)) {
			return false;
		}

		$conditions = [CAKE_SETTINGS_APP_LDAP_ATTRIBUTE_DISTINGUISHED_NAME => $groupDn];
		$fields = [CAKE_SETTINGS_APP_LDAP_ATTRIBUTE_DISTINGUISHED_NAME];
		$group = $this->find('first', compact('conditions', 'fields'));
		if (empty($group)) {
			return false;
		}
		if (empty($userGuid)) {
			return true;
		}

		$conditions = [CAKE_SETTINGS_APP_LDAP_ATTRIBUTE_OBJECT_GUID => GuidStringToLdap($userGuid)];
		$fields = [CAKE_SETTINGS_APP_LDAP_ATTRIBUTE_MEMBER_OF];
		$userInfo = $this->find('first', compact('conditions', 'fields'));
		if (empty($userInfo) ||
			!isset($userInfo[$this->alias][CAKE_SETTINGS_APP_LDAP_ATTRIBUTE_MEMBER_OF]) ||
			empty($userInfo[$this->alias][CAKE_SETTINGS_APP_LDAP_ATTRIBUTE_MEMBER_OF])) {
			return false;
		}
		$groupsDn = (array)$userInfo[$this->alias][CAKE_SETTINGS_APP_LDAP_ATTRIBUTE_MEMBER_OF];
		if (!in_array($groupDn, $groupsDn)) {
			return false;
		}

		return true;
	}
1080840
function checkGroup(query, group) {
    if (group instanceof Array) {
      // check each condition from group
      for ( var c in group) {
        check(query, group[c]);
      }
    }
  }
1068269
public function selectionExist($group_name, $name = 'group')
    {
        if(!array_key_exists($group_name, $this->units))
        {
            return false;
        }

        if(!array_key_exists($name, $this->units[$group_name]))
        {
            return false;
        }

        return true;
    }
756628
function group($group)
    {
        if (!empty($group))
        {
            self::sql_safe($group);
            $this->group = "group by $group";
        }
        else
        {
            $this->group = '';
        }
    }
194418
public function exists($key)
    {
        // Checks if we need to verify a nested array
        if (preg_match('/\.+/', $key))
        {
            $keys   = explode('.', $key);
            $levels = count($keys);

            // Quick workaround
            if ($levels == 4)
            {
                return isset($this->params[$keys[0]][$keys[1]][$keys[2]][$keys3]);
            }
            else if ($levels == 3)
            {
                return isset($this->params[$keys[0]][$keys[1]][$keys[2]]);
            }
            else
            {
                return isset($this->params[$keys[0]][$keys[1]]);
            }
        }

        // Non-nested array validation
        if (array_key_exists($key, $this->params))
        {
            return true;
        }

        return false;
    }
1055089
function (groupId) {
        server.state.set('groups[' + groupId + ']', []);
        let hasNonEmptyGroups = false;
        server.state.get('groups').forEach(function (e) {
            if (!Utils.isNullOrEmpty(e)) {
                hasNonEmptyGroups = true;
            }
        });
        if (hasNonEmptyGroups) {
            log.info('Successfully deleted group:', groupId);
        } else {
            server.state.set('groups', []);
            log.info('Successfully deleted all groups');
        }
    }
696863
function localExists() {
  var testKey = 'test';
  if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
    try {
      window.sessionStorage.setItem(testKey, '1');
      window.sessionStorage.removeItem(testKey);
      return true;
    } catch (error) {
      _logger2.default.error({
        description: 'Error saving to session storage', error: error,
        obj: 'storage', func: 'localExists'
      });
      return false;
    }
  }
  return false;
}
944791
protected function _isGroupValid( $oGroup )
    {
        return ( !empty( $oGroup->oxgroups__oxactive->value ) and !empty( $oGroup->oxgroups__oxtitle->value ) );
    }
475919
public function ensureUserGroupExists( $name, $parentGroupName = null )
    {
        if ( $parentGroupName )
        {
            // find parent group name
            $searchResults = $this->searchUserGroups( $parentGroupName );
            if ( !empty( $searchResults ) )
            {
                $parentGroup = $this->loadUserGroup( $searchResults[0]->valueObject->contentInfo->id );
                $parentGroupLocationId = $searchResults[0]->valueObject->contentInfo->mainLocationId;
            }
            else
            {
                // parent group not found, create it
                $parentGroup = $this->createUserGroup( $parentGroupName );
                $parentGroupLocationId = $parentGroup->getVersionInfo()->getContentInfo()->mainLocationId;
            }
        }
        else
        {
            $parentGroup = null;
            $parentGroupLocationId = null;
        }

        $searchResults = $this->searchUserGroups( $name, $parentGroupLocationId );

        if ( !empty( $searchResults ) )
        {
            // found existing child group, return it
            return $this->loadUserGroup( $searchResults[0]->valueObject->contentInfo->id );
        }
        // else, did not find existing group - create one with given name.
        return $this->createUserGroup( $name, $parentGroup );
    }
1025999
def uid_exists?(uid, groups=[])
      uid = Integer(uid)
      user_exists = Etc.getpwuid(uid).uid == uid
      if groups.empty?
        user_belongs = true
      else
        mem = Set.new
        username = Etc.getpwuid(uid).name
        Etc.group { |g| mem << g.name if g.mem.include?(username) }
        user_belongs = groups.all? { |g| mem.include?(g) }
      end

      user_exists && user_belongs
    rescue ArgumentError
      false
    end
318287
public function isLeaderOf($group): bool
    {
        $group = $this->resolveGroup($group);

        return $this->leadingGroups()->where('group_id', is_int($group) ? $group : $group->id)->exists();
    }