Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 21:12
    D1mon starred dry-rb/dry-matcher
  • 15:44
    graudeejs starred dry-rb/dry-container
  • 08:41
    esparta commented #366
  • 08:39
    flash-gordon commented #366
  • 08:39

    flash-gordon on master

    Fix error on Dry::Types::Array#… Merge pull request #366 from es… (compare)

  • 08:39
    flash-gordon closed #366
  • 08:38
    flash-gordon closed #362
  • 08:38
    flash-gordon commented #362
  • 08:37
    flash-gordon closed #361
  • 08:37
    flash-gordon commented #361
  • 07:48

    solnic on master

    Adding missing built-in predica… Merge pull request #65 from esp… Merge branch 'release-1.0' (compare)

  • 07:47

    solnic on release-1.0

    Adding missing built-in predica… Merge pull request #65 from esp… (compare)

  • 07:47
    solnic closed #65
  • 07:29
    esparta opened #65
  • 07:06
  • 06:23
    robturtle starred dry-rb/dry-monads
  • 05:15
    Travis esparta/dry-types (array_try_specs) passed (4)
  • 05:12
    esparta opened #366
  • Oct 21 20:38
    patrickclery commented #361
  • Oct 21 19:47
    samdindyal starred dry-rb/dry-container
Nikita Shilnikov
@flash-gordon
time will tell lolol
Gustavo Caso
@GustavoCaso
lolol
Chris Richards
@cmrichards
So the latest dry-validation, with it's Dry::Validation.Params, no-longer works with Reform :-(
Nikita Shilnikov
@flash-gordon
why?
dry-validation follows semver as other dry- and rom- gems do
this was a breaking change so reform has to be updated accordingly
and on top of it there is a backward compatibility script that should make it work anyway
it’s mentioned in the changelog
Tim Riley
@timriley
Couple of small releases today:
Jaromír Červenka
@Cervajz
:heart_eyes:
Chris Richards
@cmrichards
Is it possible to have an optional key with dry-struct?
Pavel Argentov
@argent-smith
attribute :foo, Types::Bar.meta(omittable: true)
Chris Richards
@cmrichards
Thanks
Pavel Argentov
@argent-smith
or, in the struct class body:
transform_types { |t| t.meta(omittable: true) } -- this makes all attributes omittable
Chris Richards
@cmrichards
Does setting omittable mean that the type won't be enforced for new objects?
Or should a default be set to avoid a type problem?
Nikita Shilnikov
@flash-gordon
fwiw, it only makes sense to use omittable for optional types
but I think it's also possible not to have optional
also, you don't need omittable for default types, it's implied
Chris Richards
@cmrichards
What's the best way to create json from dry-struct objects in rails? to_json works, but it doesn't let me pick additional methods on the structs to include in the json
Tim Riley
@timriley
Some kind of serializer object is probably best, @cmrichards
Lairan
@alex-lairan
Igor S. Morozov
@Morozzzko

Hey everyone!

I’ve just noticed that dry-rb/dry-rb.org#154 tried to close 7 issues at once. But GitHub has only marked one of them as resolved. Could someone please close the rest of them?

Gustavo Caso
@GustavoCaso
@Morozzzko Thanks for spotting it
I just closed the missing ones
Ryan Bigg
@radar
What is the alternative to constructor_type :schema now to allow an attribute key to be missing by default?
Oh I think I saw it above: transform_types { |t| t.meta(omittable: true) }
Nope, that's not it...
https://github.com/radar/exploding-rails-examples/tree/0ec2eaed049e7fb7542ba1117b71b83c78cee345 <- Here's my code. It's the ticketee project. It has a failing test like this:
``` Failure/Error: @project = Projects::Project.new
 Dry::Struct::Error:
   [Projects::Project.new] :id is missing in Hash input```
I'm out of time for that today, but I'll revisit this tomorrow morning. Thanks in advance for your help.
Nikita Shilnikov
@flash-gordon
@radar on mobile, check out dry-struct’s changelog, type transformation should work
Ryan Bigg
@radar
@flash-gordon It appears that the transform_types setting is not recognised by subclasses. I am calling transform_types within a class called ApplicationModel, but then relying on it in a class called Project that inherits from ApplicationModel. Is this the intended behaviour?
Oops, I wasn't calling it on klass within the inherited block. That'll do it.
Tim Riley
@timriley
klassic radar
Ryan Bigg
@radar
klassic.
good morning @timriley. Nice job on https://timriley.info/ :)
Tim Riley
@timriley
hah, thank you :) It is built on dry-system and dry-view, so I suppose it is appropriate for this room!
Chris Richards
@cmrichards
Chris Richards
@cmrichards
Also wondering how ROM would fit into this code.
Tim Riley
@timriley
@cmrichards maybe you could tell us what worries you about that code?
Chris Richards
@cmrichards

I'm not sure if I should be directly accessing the ActiveRecord objects here to create new objects, e.g.

quote_group.quote_items.active.create!(..

I'm not really sure where else this should go. I wonder if it would be better to centralise the all code that uses ActiveRecord objects like this, or if it's safe enough to live here. Perhaps there is a cleaner way using rom?

Also, I wonder if this:

def call(attempt_id:, test_ids:, quote_group_id:)
  result = Schema.({
    attempt_id: attempt_id,
    test_ids: test_ids,
    quote_group_id: quote_group_id,
  })

should be this:?

def call(args)
    result = Schema.(args)
Chris Richards
@cmrichards
The dry- libraries are truly excellent libraries. I'm not sure how I ever lived without dry-validation/struct! I'd love to contribute financially somehow. Maybe a book is on the way?
Jaromír Červenka
@Cervajz
Hello:) Based on @radar 's book (nice job :+1:) I started to write my services as transactions and the validation layer in dry-validation. Staying with AR for now - just for storing data and for realationships only. Quick quesion: How do you feel about having different validation schemas for different trasnactions? As I am thinking about validations not on the "model level" (aka User.validates :email, presence: true) but on the "operation level". Does it make any sense? How do you use it?
For example:
# app/schemas/users/user_schema.rb:1
module Users
  UserSchema = Dry::Validation.Schema(ApplicationSchema) do
    required(:full_name).filled(:str?)
    required(:email).filled(:str?, :email?, unique?: :email)
    required(:country).filled(:str?)
    required(:password).filled(:str?, min_size?: 5)

    optional(:phone).maybe(:str?)
    optional(:admin).maybe(:bool?)
    optional(:blocked).maybe(:bool?)
  end
end

# app/schemas/users/confirm_new_password_schema.rb:1
module Users
  ConfirmNewPasswordSchema = Dry::Validation.Schema(ApplicationSchema) do
    required(:authentication_token).filled(:str?)
    required(:password).filled(:str?, min_size?: 5)
  end
end
Both of them are still related to User model but used in different situations
Tim Riley
@timriley
@Cervajz yes, I 100% endorse this! Validations should be specific to each distinct user action or use case.
Jaromír Červenka
@Cervajz
@timriley Cool :)