> For the complete documentation index, see [llms.txt](https://marick.gitbook.io/idiosyncratic-elixir/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://marick.gitbook.io/idiosyncratic-elixir/declarative-testing-of-structured-form-input/consistent-parameter-handling/creating-and-validating-a-changeset.md).

# Describing changeset validations

A particular test's expected results can be described with `changeset` (lines 4-5):

```elixir
    category(                           :success,
      ok: [
        params(      age: 1, date:   "2001-01-01"),
        changeset(
          changes: %{age: 1, date: ~D[2001-01-01]}
        )]
    ) |> 

```

That constructs (in effect) this assertion pipeline:

```elixir
Schema.changeset(%Schema{}, Tester.params(:ok))
|> assert_valid
|> assert_changes(age: 1,
                  date: ~D[2001-01-01])
```

Notice that the `assert_valid` wasn't made explicit. It's implied by the name of the category: `:success`(line 1). (Similarly, the`:validation_failure`category implies `assert_invalid`.)

The `changeset` function supports all of the [changeset assertions from ecto\_flow\_assertions](https://hexdocs.pm/ecto_flow_assertions/FlowAssertions.Ecto.ChangesetA.html#summary). Just leave off the `assert_` prefix and the `changeset` argument. For example:

```elixir
    category(                 :validation_failure,
      bad_date: [
        params(    age: 1, date: "2001-1-1"),
        changeset(
          changes: %{age: 1},
          no_changes: [:date],
          errors: [date: ~r/invalid/]
        )]
      )

```

Because this code reuses `ecto_flow_assertions`and `ecto_flow_assertions` reuses `ExUnit`'s reporting machinery, you get good error messages:

![colorization! and more!](https://902287157-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MHC8R84w1IeNZSD7hAh%2F-MKVTvdXuuJFVEOAC4IK%2F-MKVZjM_ioubwGMXZquQ%2FScreen%20Shot%202020-10-25%20at%2011.23.33%20AM.png?alt=media\&token=235b2120-071d-41e8-a0cc-3ec88955b64e)

That's important because test generation frameworks are notorious for creating errors that are hard to understand.
