Orange-Men

Orange-Men

Get data from previous changeset

Hi to all!
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?

Marked As Solved

wmnnd

wmnnd

You can use Ecto.Changeset.validate_change/4 on the :legs field.

Last Post!

Orange-Men

Orange-Men

You damn right!
Thank you very much!
Sorry, I did not know that I can use ‘validate_change’ on the field like ‘legs’.

Where Next?

Popular in Discussions Top

mbenatti
Following https://github.com/tbrand/which_is_the_fastest |> https://raw.githubusercontent.com/tbrand/which_is_the_fastest/master/imgs...
New
pillaiindu
In django there is a cache framework backed by memcached. Rails also puts a lot of emphasis on caching, and even the idea of russian-doll...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
mikl
I wanted to capitalize a string, and tried using String.capitalize(). That generally works well, until you try to capitalize a word like...
New
marciol
Please, let me know if this kind of discussion already took place in another topic . Hi all, how do you consider if is better to build ...
New
RudManusachi
What configs will make sense to put to runtime.exs? – A bit of how I configure apps: I have generic configs in config/config.exs, dev...
New
pillaiindu
I want to convert a Phoenix LiveView CRUD website to a CRUD mobile app. What do you think is the easiest way to do so?
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

We're in Beta

About us Mission Statement