-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use FieldState to collect validation data
- Loading branch information
1 parent
fa4c298
commit 9bfcfab
Showing
7 changed files
with
8,032 additions
and
1,898 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
defmodule PrimerLive.FieldState do | ||
@moduledoc """ | ||
State object with validation data for a particular form field. | ||
Struct fields: | ||
- `changeset` - `Ecto.Changeset` struct. | ||
- `field_errors` - changeset `errors`, filtered for the field. | ||
- `valid?` - True if changeset's `field_errors` is empty for the field. | ||
- `message` - Default message derived from changeset `errors`, unless overridden by `validation_message` attribute. | ||
- `message_id` - Generated id that is used for `aria_describedby`. | ||
""" | ||
defstruct valid?: false, changeset: nil, message: nil, message_id: nil, field_errors: [] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.