Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Apr 22 18:05
    ytaben commented #72
  • Apr 22 18:05
    ytaben commented #72
  • Apr 22 18:04
    ytaben commented #72
  • Apr 22 14:16
    ytaben synchronize #72
  • Apr 22 14:04
    ytaben synchronize #72
  • Apr 22 12:55

    timriley on master

    Bump dry-system to 0.19.0 (compare)

  • Apr 22 12:55

    timriley on v0.19.0

    Bump dry-system to 0.19.0 (compare)

  • Apr 22 12:49

    dry-bot on master

    [devtools] sync (compare)

  • Apr 22 12:48

    timriley on master

    Update changelog (compare)

  • Apr 22 12:48

    dry-bot on master

    [devtools] sync (compare)

  • Apr 22 12:47

    timriley on master

    Update changelog (compare)

  • Apr 22 06:26
    solnic review_requested #72
  • Apr 22 06:26
    solnic commented #72
  • Apr 22 01:57

    dry-bot on master

    [devtools] sync (compare)

  • Apr 22 01:57

    timriley on master

    Fix changelog (compare)

  • Apr 22 01:34

    dry-bot on master

    [devtools] sync (compare)

  • Apr 22 01:34

    timriley on master

    Add changelog entry for 0.19.0 … (compare)

  • Apr 22 01:34

    timriley on add-0-19-0-changelog

    (compare)

  • Apr 22 01:34
    timriley closed #161
  • Apr 22 01:27
    samkcarlile starred dry-rb/dry-monads
Nikita Shilnikov
@flash-gordon
I do have a few methods like this, don't see anything harmful since it's not the same as having an AR-model :)
Grant Shangreaux
@gcentauri
haha thanks
ruby often feels like a slippery slope to me in those regards
Jules Ivanic
@guizmaii

Hi everyone,

I’m using the Task monad and I saw that there’s a pure function but there’s not its “dual” failed (equivalent of Concurent::Promise.reject).

How would you implement it ?

I don’t want to throw exception. Just create an immedialty failed Task
(throwing is expensive in JRuby)

is this something sensible:

    def failed(error)
      Dry::Monads::Task.new(Concurrent::Promise.reject(error))
    end

???

This message was deleted
Nikita Shilnikov
@flash-gordon
@guizmaii yeah, we should have it, no particular reason we don't have, just no one asked for it
Jules Ivanic
@guizmaii
If I have time I’ll push you a PR
Nikita Shilnikov
@flash-gordon
:+1:
Jules Ivanic
@guizmaii
def failed(error, &block) signature looks ok for you ? With the same Undefined trick as in pure ?
Nikita Shilnikov
@flash-gordon
not sure because answering this question would pre-emptying my current brain stack :)
Jules Ivanic
@guizmaii
k. We’ll talk about that around a good old PR so
:)
Tonni Tølbøll Lund Aagesen
@ta
Hello, How do I get transform_keys(&:to_sym) to work with nested structs? It works fine with 1st level attributes.
Nikita Shilnikov
@flash-gordon
create and use the same base class across your structs
Tonni Tølbøll Lund Aagesen
@ta
Nikita Shilnikov
@flash-gordon
similar but I think you want to nested structs rather nested schemas
class MyStruct < Base
  attribute :id, Types::Strict::Integer
  attribute :data do
    attribute :code, Types::Strict::Integer.optional.default(nil)
    attribute :msg,  Types::String.optional.default(nil)
  end
end
like that^
Tonni Tølbøll Lund Aagesen
@ta
MyStruct.new({"id" => 1, "data" => { "code" => 200 }}) still doesn't set the code attribute :/
Nikita Shilnikov
@flash-gordon
lemme look into this
Tonni Tølbøll Lund Aagesen
@ta
but thanks for the nested structs hint :)
cool
Nikita Shilnikov
@flash-gordon
change, attribute :data do to attribute(:data, Base) do
because it's not usign Base as default there but Dry::Struct
Tonni Tølbøll Lund Aagesen
@ta
yes, was about to write that solution :)
can there be an argument for having nested structs inherit from parent struct?
Nikita Shilnikov
@flash-gordon
we could have a means for that
I'm not sure what's the best here but having something would be nice
I came across this pattern a copule of times
Tonni Tølbøll Lund Aagesen
@ta
Thanks for helping out
oh btw, can a nested struct be optional like a nested schema?
Nikita Shilnikov
@flash-gordon
you mean absence of key or nil as a value?
Tonni Tølbøll Lund Aagesen
@ta
I have Types::Hash.schema( ... ).optional.default(nil) in some structs
Nikita Shilnikov
@flash-gordon
class MyStruct < Base
  attribute :id, Types::Strict::Integer
  attribute :data, Class.new(Base) {
    attribute :code, Types::Strict::Integer.optional.default(nil)
    attribute :msg,  Types::String.optional.default(nil)
  }.optional
end
that's the closest thing I can think of
and that's not good enough
feel free to post both suggestions to GH and we'll sort it out eventually
Tonni Tølbøll Lund Aagesen
@ta
will do, thx
Tonni Tølbøll Lund Aagesen
@ta
oh my, what one can learn from reading the docs more closely: Types::Hash.schema(name: Types::Strict::String).with_key_transform(&:to_sym) :)
Nikita Shilnikov
@flash-gordon
yeah, if you don't need structs you can use schemas, they also support kind of inheritance
I prefer DSL for describing structs, this is basically it
Jaromír Červenka
@Cervajz
Off topic: Anyone heading to ElixirConf in Prague? :)
Oskar Szrajer
@gotar
Hi, I'm trying to validate something like this in dry-v. a field values is any array of strings, if inside those array there is a value 'foo' it must validate presence of 'bar', 'baz' too, so something like
values.include?('foo') > values.include?('bar') & values.include?('baz')
is it possible? I don't have any good idea how to achieve this
Vasily Kolesnikov
@v-kolesnikov
I would prefer to avoid that validation at all, even if dry-v could do it. It sounds strange to have data like unstructured array of strings. Could you give a real example of usage the data like that?
Oskar Szrajer
@gotar
User select answers in a form, it's a checkbox (multiselect) is he select one from them he must select some others.
I found some solution, just a custom predicate, works ok-ish ;]
Vasily Kolesnikov
@v-kolesnikov
:ok_hand: