Update
This commit is contained in:
parent
1b6f6bb36a
commit
541187c3ea
|
@ -39,7 +39,7 @@ a {
|
||||||
color: #0000ff80; /* rgba(0, 0, 255, 0.5) */
|
color: #0000ff80; /* rgba(0, 0, 255, 0.5) */
|
||||||
|
|
||||||
color: hwb(90, 0%, 0%, 0.5); /* like hsl() but easier for humans */
|
color: hwb(90, 0%, 0%, 0.5); /* like hsl() but easier for humans */
|
||||||
color: hsl(90deg 90% 70%%); /* hsl(180, 90%, 70%) -- supports deg */
|
color: hsl(90deg 90% 70%); /* hsl(180, 90%, 70%) -- supports deg */
|
||||||
color: hsl(90deg 90% 70% / 30%); /* hsla(180, 90%, 70%, 0.3) */
|
color: hsl(90deg 90% 70% / 30%); /* hsla(180, 90%, 70%, 0.3) */
|
||||||
color: rgb(30 60 90 / 30%); /* rgba(30, 60, 90, 0.3) */
|
color: rgb(30 60 90 / 30%); /* rgba(30, 60, 90, 0.3) */
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,9 @@ end
|
||||||
|
|
||||||
```elixir
|
```elixir
|
||||||
def changeset(user, params \\ :empty) do
|
def changeset(user, params \\ :empty) do
|
||||||
|
%User{}
|
||||||
|
|> Ecto.Changeset.change # basic casting to changeset
|
||||||
|
|
||||||
user
|
user
|
||||||
|> cast(params, ~w(name email), ~w(age)) # params to Changeset
|
|> cast(params, ~w(name email), ~w(age)) # params to Changeset
|
||||||
|
|
||||||
|
@ -54,8 +57,8 @@ def changeset(user, params \\ :empty) do
|
||||||
|
|
||||||
|> unique_constraint(:email)
|
|> unique_constraint(:email)
|
||||||
|> foreign_key_constraint(:post_id)
|
|> foreign_key_constraint(:post_id)
|
||||||
|> assoc_constraint(:post) # ensure post_id exists
|
|> assoc_constraint(:post) # ensure post_id exists
|
||||||
|> exclude_constraint(:name)
|
|> no_assoc_constraint(:post) # negative (useful for deletions)
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -64,7 +67,8 @@ changeset.valid?
|
||||||
changeset.errors #=> [title: "empty"]
|
changeset.errors #=> [title: "empty"]
|
||||||
|
|
||||||
changeset.changes #=> %{}
|
changeset.changes #=> %{}
|
||||||
changeset.params
|
changeset.params[:title]
|
||||||
|
|
||||||
changeset.required #=> [:title]
|
changeset.required #=> [:title]
|
||||||
changeset.optional #=> [:body]
|
changeset.optional #=> [:body]
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue