Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Philip Arndt
@parndt
Yeah :D
 @relation=
  #<ROM::Relation[Contents] dataset=#<Sequel::Postgres::Dataset: "SELECT \"id\", \"content_type_id\", \"value_schema\", \"created_at\", \"updated_at\" FROM \"contents\" WHERE (\"value_schema\" @> '{\"slug\":\"my-page\"}'::jsonb) ORDER BY \"contents\".\"id\"">>>
pretty happy with that :)
Piotr Solnica
@solnic
cool stuff huh? sequel kicks ass, and rom-sql 1.0.0 even makes it better
Philip Arndt
@parndt
yeah!! I am agreeing with you now
all it took was staying up until midnight
Piotr Solnica
@solnic
yeah learning curve
I’ll start documenting all of that prior the release
Philip Arndt
@parndt
it's just "hey, I know how to do this already, but I don't know the syntax with this library"
Philip Arndt
@parndt
thanks for all the help :+1: goodnight :sleeping:
Ghost
@ghost~545771cbdb8155e6700d0a6f
hey guys, is there any documentation about dry-web ?
Tim Riley
@timriley
@ahmgeek not yet sorry, hopefully within the next month
Chris Richards
@cmrichards
Is there a good example app on github that uses dry
-rb?
Sergey Kukunin
@Kukunin
https://github.com/icelab/berg - canonical app =)
Chris Richards
@cmrichards
Thanks 😀
Does it use dry-validation / forms and all that jazz?
Piotr Solnica
@solnic
@cmrichards dry-validation. I'll be updating it soon to rom 3.0.0 but there won't be any form objects
Jan Stevens
@JanStevens
Is there any other way to define Dry::Validation.Schema in a ruby syntax way? I’m not really a fan of the assign to constant that looks like a class
class Devices
  extend Dry::Initializer::Mixin
  Schema = Dry::Validation.Schema do
    required(:status_update_interval_s).filled
  end
end
Also I’m trying to combine Dry Initializer (or struct) with Validation
Piotr Solnica
@solnic
class Schema < Dry::Validation::Schema
  define! do
    required(:foo).filled
  end
end

my_schema = Schema.new
@JanStevens ^
Jan Stevens
@JanStevens
Ha nice :0
and any guide / wiki on how to combine Dry-struct + dry validations? I was reading the Invalid object is an anti pattern and now I’m a bit puzzled where to place my validations (for example value should be larger then 20)
Piotr Solnica
@solnic
@JanStevens combine in what way?
Jan Stevens
@JanStevens
in the article custom types are created that behave as validation
Sergey Kukunin
@Kukunin
@JanStevens dry-type validates struct by default, without dry-validation
Piotr Solnica
@solnic
these should be treated like constraints, not validation
Sergey Kukunin
@Kukunin
yep. good clarification. dry-structs has constraints
Jan Stevens
@JanStevens
I get user input from a form, and want to validate the input matches the constraints
Sergey Kukunin
@Kukunin
and there is separate validation schema for an input outside of applciation
Piotr Solnica
@solnic
@JanStevens and then you want to build a struct from that input?
Jan Stevens
@JanStevens
yes indeed
Piotr Solnica
@solnic
yeah we have partial support for importing struct constraints into a dry-validation schema
Jan Stevens
@JanStevens
Ha I see, so the contraints make sure the struct is valid object, the validations are more for different kind of inputs
Piotr Solnica
@solnic
validation is different from constraints because it does not cause exceptions
Sergey Kukunin
@Kukunin
@solnic what is partial support btw?
Piotr Solnica
@solnic
@Kukunin it may or may not work :)
so it’s in experimental state
Jan Stevens
@JanStevens
so the flow would be, Get user input -> Validate using schema -> initialize object -> work it
you can also just reuse types in both dry-v and dry-s
so ie Age = Types::Int.constrained(gt: 18) and use it in a validation schema like required(:age).filled(:int?, Age)
Jan Stevens
@JanStevens
so your types should also deal with the defaults?
Piotr Solnica
@solnic
ah for defaults you’d have to enable type_specs and do this:
uhm, ok nevermind, defaults don’t work yet
tbh I don’t even know if it’s a good idea to make them work in dry-v
they will work in structs though, so if you want to treat structs as an intermediate step to prepare data then you’ll get defaults
Jan Stevens
@JanStevens
So the order would be different then
Initialize struct -> validate using schema?
Piotr Solnica
@solnic
uhm no