---
title: "debug.validlevel"
description: "Checks whether a numeric level is within the thread's native frame count."
---

```lua
debug.validlevel(level: number, thread: thread?): boolean
```

---

## Aliases

- `debug.isvalidlevel`
- `validlevel`
- `isvalidlevel`

---

## Arguments

<ParamField body="level" type="number" required>
  The stack-frame level to inspect. See this function's frame-numbering rules below.
</ParamField>

<ParamField body="thread" type="thread">
  The coroutine whose environment, script association, or stack is inspected.
</ParamField>

---

## Returns

<ResponseField name="result" type="boolean">
  Whether the queried condition holds.
</ResponseField>

Tests level >= 0 and level < stacksize. Does not guarantee that a different debug API will accept that frame or that it is a Lua closure.

**Related types:** [Debug types & behavior](/reference/debug/types).

---

## Example

```lua
print(debug.validlevel(1))
```
