# `Beancount.Checker`
[🔗](https://github.com/thanos/beancount_ex/blob/v0.6.0/lib/beancount/checker.ex#L1)

Low-level wrapper around the `bean-check` command-line tool.

`Checker` is the only place that shells out to Beancount. It is used by
`Beancount.Engine.CLI` and is kept separate so the process-management
concerns (locating the binary, temp files, capturing output) live in one
place.

The path to `bean-check` is configurable:

    config :beancount_ex, bean_check_path: "bean-check"

# `available?`

```elixir
@spec available?() :: boolean()
```

Whether the configured `bean-check` executable is available on this machine.

## Examples

    iex> is_boolean(Beancount.Checker.available?())
    true

# `bean_check_path`

```elixir
@spec bean_check_path() :: String.t()
```

Return the configured path to the `bean-check` executable.

## Examples

    iex> is_binary(Beancount.Checker.bean_check_path())
    true

# `check_file`

```elixir
@spec check_file(Path.t()) ::
  {:ok, Beancount.Result.t()} | {:error, Beancount.Result.t()}
```

Check a `.bean` file on disk, returning a normalized `Beancount.Result`.

Raises `Beancount.Checker.NotInstalledError` if `bean-check` is not available.

## Examples

    path = Path.join(System.tmp_dir!(), "checker_example.bean")

    File.write!(path, """
    2026-01-01 open Assets:Bank USD
    2026-01-01 open Income:Salary USD

    2026-01-31 * "Employer" "Salary"
      Assets:Bank     100 USD
      Income:Salary  -100 USD
    """)

    if Beancount.Checker.available?() do
      {:ok, _} = Beancount.Checker.check_file(path)
    end

# `check_text`

```elixir
@spec check_text(binary()) ::
  {:ok, Beancount.Result.t()} | {:error, Beancount.Result.t()}
```

Check Beancount text by writing it to a temporary file and validating it.

## Examples

    text = """
    2026-01-01 open Assets:Bank USD
    2026-01-01 open Income:Salary USD

    2026-01-31 * "Employer" "Salary"
      Assets:Bank     100 USD
      Income:Salary  -100 USD
    """

    if Beancount.Checker.available?() do
      {:ok, %Beancount.Result{status: :ok}} = Beancount.Checker.check_text(text)
    end

---

*Consult [api-reference.md](api-reference.md) for complete listing*
