> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ubiquex.io/llms.txt
> Use this file to discover all available pages before exploring further.

# ubx validate

> Type-check .iac files without deploying. No cloud credentials required.

`ubx validate` runs the full compiler pipeline without generating TypeScript or deploying. Fast — no cloud credentials required.

## Usage

```bash theme={null}
ubx validate [path] [flags]
```

## Examples

```bash theme={null}
ubx validate                   # all .iac in current directory
ubx validate main.iac          # specific file
ubx validate ./stacks/net      # specific directory
ubx validate --compile         # also run tsc --noEmit
ubx validate --cost            # check cost_limit (requires AI)
ubx validate --env prod        # with environment overrides
```

## Flags

| Flag             | Description                                             |
| ---------------- | ------------------------------------------------------- |
| `--compile`      | Also run `tsc --noEmit` on generated TypeScript         |
| `--cost`         | Check `cost_limit` attributes against AI cost estimates |
| `--env string`   | Target environment                                      |
| `--stack string` | Target stack name                                       |

## Output

Success:

```
  ◆ Compile    stack.iac
  ✓  valid
```

With errors:

```
  ◆ Compile    stack.iac

  ✗  stack.iac:3  required attribute "engine" is missing from unit "db" (aws_rds_instance)
  ✗  stack.iac:7  unknown attribute "fake_field" on aws_s3_bucket_v2

  ✗  2 error(s)
```

With warnings:

```
  ◆ Compile    stack.iac

  ⚠  stack.iac:5  attribute "acl" is not a known field of aws_s3_bucket_v2
  ✓  valid  (1 warning(s))
```

## What Gets Validated

* **Syntax** — valid `.iac` block structure
* **Required fields** — all required provider attributes present
* **Unknown fields** — warn on attributes not in schema
* **References** — all `~unit.x.y.z`, `local.name`, `input.name` refs exist
* **Circular dependencies** — detected and reported
* **Policy blocks** — all `policy` rules evaluated
* **`cost_limit`** — validated with AI when `--cost` is set

## `--compile` Flag

Runs `tsc --noEmit` after schema validation. Requires Node.js.

```
  ◆ Compile    stack.iac
  ✓  valid

  ◆ TypeScript compiling generated code...
  ✓  TypeScript valid
```

## Exit Codes

| Code | Meaning                     |
| ---- | --------------------------- |
| `0`  | Valid (warnings don't fail) |
| `1`  | One or more errors          |
