I have the set of data for airports tickets:
%{
class: "economy",
legs: [
%{date: "2018-08-01", from: ["FRA"], to: ["LON"]},
%{date: "2018-08-10", from: ["LON"], to: ["FRA"]}
],
passengers: %{adults: 1, children: 0, infants: 0}
}
I am using cast_assoc
for legs:
...
|> cast(attrs, [:passengers, :class])
|> cast_assoc(:legs)
...
I need to check that the dates in the right order (date of first flight needs to be before the date of second flight). How can I get the value of date previous changeset?
I did not know that I can use 'validate_change' on the field like 'legs'.
https://elixirforum.com/t/get-data-from-previous-changeset/15356/2?u=orange-men
Thx to wmnnd