Skip to content

Commit

Permalink
docs: improve README
Browse files Browse the repository at this point in the history
  • Loading branch information
tlux committed Mar 24, 2024
1 parent cd2cd8f commit 225dfa4
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,37 @@ end

## Usage

With Vx, you can define schemata to validate complex data against.
With Vx, you have the capability to define schemata for validating complex data
effortlessly.

You first need to define your schema.

```elixir
schema = Vx.String.t()
```

Then, you can call `Vx.validate/2` or `Vx.validate!/2` to check if a given
After that, you can call `Vx.validate/2` or `Vx.validate!/2` to check if a given
values matches:

```elixir
Vx.validate(schema, "foo")
# :ok
```

When the value does not match, an error is returned (or raised respectively)
pointing out what is wrong:
When the value does not match, an error is returned (or raised, respectively),
indicating the specific issue.

```elixir
Vx.validate(schema, 123)
# {:error, %Vx.Error{...}}
```

```elixir
Vx.validate!(schema, 123)
# ** (Vx.Error) must be a string
```

Some types can be augmented with additional constraints by piping everything
Additional constraints can be added to certain types by piping everything
together:

```elixir
Expand Down

0 comments on commit 225dfa4

Please sign in to comment.