Packages

Declarative Ecto embedded schemas for data validation, coercion, and manipulation.

Current section

12 Versions

Jump to

Compare versions

5 files changed
+10 additions
-8 deletions
  @@ -1,6 +1,6 @@
1 1 {<<"links">>,[{<<"GitHub">>,<<"https://github.com/acalejos/flint">>}]}.
2 2 {<<"name">>,<<"flint">>}.
3 - {<<"version">>,<<"0.5.0">>}.
3 + {<<"version">>,<<"0.5.1">>}.
4 4 {<<"description">>,
5 5 <<"Declarative Ecto embedded schemas for data validation, coercion, and manipulation.">>}.
6 6 {<<"elixir">>,<<"~> 1.14">>}.
  @@ -3,11 +3,11 @@ defmodule Flint.Extension do
3 3 `Flint` extensions allow developers to easily hook into `Flint` metaprogramming lifecycle to add extra data into the embedded
4 4 schema reflection functions.
5 5
6 - Flint currently offers three ways to extend behavior:
6 + Flint currently offers four ways to extend behavior:
7 7
8 8 1. Schema-level attributes
9 9 2. Field-level additional options
10 - 3. Default `field` and `field!` definitions
10 + 3. Default `embedded_schema` definitions
11 11 4. Injected Code
12 12
13 13 Extension authors define what fields / options / attributes `Flint` should look for in the module / schema definition and
  @@ -22,7 +22,6 @@ defmodule Flint.Extensions.EctoValidations do
22 22 * `:min` ([`Ecto.Changeset.validate_length/3`](https://hexdocs.pm/ecto/Ecto.Changeset.html#validate_length/3-options))
23 23 * `:max` ([`Ecto.Changeset.validate_length/3`](https://hexdocs.pm/ecto/Ecto.Changeset.html#validate_length/3-options))
24 24 * `:count` ([`Ecto.Changeset.validate_length/3`](https://hexdocs.pm/ecto/Ecto.Changeset.html#validate_length/3-options))
25 - * `:when` - Let's you define an arbitrary boolean condition on the field which can refer to any `field` defined above it or itself. **NOTE** The `:when` option will output a generic error on failure, so if verbosity is desired, an [advanced validation](#advanced-validations) is more appropriate.
26 25
27 26 ## Aliases
28 27
  @@ -159,7 +158,7 @@ defmodule Flint.Extensions.EctoValidations do
159 158 validate_subset: validate_subset_arg
160 159 ]
161 160 |> Enum.map(fn
162 - {k, args} when is_list(args) ->
161 + {k, args} when k in [:validate_number, :validate_length] ->
163 162 {k, Enum.reject(args, fn {_k, v} -> is_nil(v) end)}
164 163
165 164 other ->
  @@ -30,7 +30,7 @@ defmodule Flint.Extensions.PreTransforms do
30 30 embedded_schema do
31 31 field! :category, Union, oneof: [Ecto.Enum, :decimal, :integer], values: [a: 1, b: 2, c: 3]
32 32 field! :rating, :integer, when: category == target_category
33 - field :score, derive: rating + category, :integer, gt: 1, lt: 100, when: score > rating
33 + field :score, :integer, derive: rating + category, gt: 1, lt: 100, when: score > rating
34 34 end
35 35 end
36 36 ```
  @@ -5,7 +5,7 @@ defmodule Flint.MixProject do
5 5 [
6 6 app: :flint,
7 7 name: "Flint",
8 - version: "0.5.0",
8 + version: "0.5.1",
9 9 elixir: "~> 1.14",
10 10 start_permanent: Mix.env() == :prod,
11 11 deps: deps(),
  @@ -49,8 +49,11 @@ defmodule Flint.MixProject do
49 49 defp docs do
50 50 [
51 51 main: "Flint",
52 + extras: [
53 + "notebooks/feature_guide.livemd"
54 + ],
52 55 groups_for_extras: [
53 - Notebooks: Path.wildcard("notebooks/*.livemd")
56 + Notebooks: ~r"notebooks/.*\.(md|livemd)"
54 57 ],
55 58 groups_for_modules: [
56 59 Types: [Flint.Type, Flint.Types.Union],