# checkAccessLevelExists

This view function checks if a specific access level exists for a given event. It takes two parameters:

* `_eventId`: The unique identifier for the event.
* `_accessLevel`: The access level to be checked for existence.

````solidity
// Some code

```remix-solidity
/**
    CheckAccessLevelExists: Check if a specific access level exists for a given event.
    @param _eventId: The unique identifier for the event.
    @param _accessLevel: The access level to be checked for existence.
    @return bool: A boolean indicating whether the access level exists for the event.
    */
    function checkAccessLevelExists(
        string calldata _eventId,
        string calldata _accessLevel
    ) public view returns (bool) {
        // Retrieve all access levels associated with the event
        string[] memory _accessLevels = getAccessLevelsFromEventId(_eventId);
        // Loop through access levels to check for the existence of the specified access level
        for (uint256 i = 0; i < _accessLevels.length; ++i) {
            if (
                keccak256(bytes(_accessLevel)) ==
                keccak256(bytes(_accessLevels[i]))
            ) {
                return true;
            }
        }
        return false;
    }
```
````

## Explanation:

The function retrieves all access levels associated with the event using the [`getAccessLevelsFromEventId` ](https://mujahid.gitbook.io/decast-gating-document/getter-view-functions)function. Then, it iterates through these access levels to check if the specified access level exists among them. It compares the keccak256 hashes of the access level strings to determine a match. If a match is found, indicating that the access level exists for the event, the function returns `true`; otherwise, it returns `false`.
