Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Apr 09 12:23
    k0va1 starred dry-rb/dry-container
  • Apr 09 08:33

    dry-bot on master

    [devtools] sync (compare)

  • Apr 09 08:33

    solnic on master

    Update changelog.yml (compare)

  • Apr 09 08:21

    solnic on v0.3.2

    Bump dry-monitor to 0.3.2 (compare)

  • Apr 09 08:20
    flash-gordon commented #38
  • Apr 09 08:19

    dry-bot on master

    [devtools] sync (compare)

  • Apr 09 08:19

    solnic on master

    Update changelog.yml rubocop --safe-auto-correct Ignore warnings from rouge gem and 1 more (compare)

  • Apr 09 08:03
    mensfeld commented #38
  • Apr 09 02:41
    DaiAoki starred dry-rb/dry-monads
  • Apr 08 23:53

    davydovanton on improve-allocation-of-logger

    (compare)

  • Apr 08 23:53

    davydovanton on master

    Don't create a new formatter ob… Merge pull request #38 from dry… (compare)

  • Apr 08 23:53
    davydovanton closed #38
  • Apr 08 18:00
    dry-bot commented #38
  • Apr 08 17:59
    davydovanton review_requested #38
  • Apr 08 17:59
    davydovanton assigned #38
  • Apr 08 17:59
    davydovanton opened #38
  • Apr 08 17:54

    davydovanton on improve-allocation-of-logger

    Don't create a new formatter ob… (compare)

  • Apr 08 17:29
    JuPlutonic starred dry-rb/dry-monitor
  • Apr 08 13:48
  • Apr 08 09:13

    solnic on release-0.17

    Add information about built-in … (compare)

Gregory Huczynski
@greghuc
@solnic I think my underlying issue is how dry-validation and dry-types fit into a web-app (JSON DB-backed API in my case). I kind of want there to be two separate parts:
  • Input validation + coercion: takes user input, normalises it and coerces into simple base types (String, DateTime, and custom types like Url and Email), and returns a hash of these typed attributes. Or errors. dry-validation might do this.
  • Immutable, typed domain objects: a domain object is defined as a set of typed attributes. The object is either constructed from validated-input-hash, or from hash-loaded-from-database. Though hash-loaded-from-database may have had some type coercion (i.e. email stored as string in DB becomes Email type), or that type coercion is built into the domain object. dry-types might work for this
Got to go - back later!
Piotr Solnica
@solnic
:laughing:
@greghuc yeah but we're still dealing with ruby primitives
require 'dry-validation'

class Email
  attr_reader :value

  def self.new(input)
    super("#{input}.com")
  end

  def initialize(value)
    @value = value
  end
end

Dry::Types.register_class(Email)

schema = Dry::Validation.Form do
  key(:email).required(type?: Email)
end

puts schema.('email' => 'jane@doe').inspect
@greghuc ^^
output:
#<Dry::Validation::Result output={:email=>#<Email:0x007fe6f2353370 @value="jane@doe.com">} messages={}>
Fran Worley
@fran-worley
@solnic is my assumption here correct?
When a predicate is curried, we can get some, all or none of the argument values. The same happens when it is called so we can't make any assumptions about what args we receive and when.
Piotr Solnica
@solnic
@fran-worley yeah, you don't know if you've got all args, there's no mechanism for that (at least not yet)
Fran Worley
@fran-worley
@solnic think I might have to add that as otherwise I'll be overriding an intentional nil.
Piotr Solnica
@solnic
@fran-worley I believe this will turn out to be useful in many places, so feel free to add it
it's a matter of storing arity
ah, failing specs first in dry-rb/dry-logic#13 nice :)
it's easier to TDD when mostly you care about inputs/outputs right? :)
Fran Worley
@fran-worley
@solnic thats my plan. What do you think about the AST change?
Piotr Solnica
@solnic
I like it, this is a pretty useful piece of info
we're gonna allocate more arrays but that shouldn't hurt esp that we can simplify code in dry-v thanks to this change
Fran Worley
@fran-worley
I don't think we can loose the input value from the result ast just yet as it isn't always exactly the same. but for error messages in dry-v it means that you can just focus on the predicate part as that has all the info including the input
Piotr Solnica
@solnic
right, the result part of dry-logic is the complicated part
I hope we can improve this over time
I esp don't like that we evaluate input two times :(
Fran Worley
@fran-worley
and when you recreate the predicate it causes all sorts of issues as I keep loosing the argument names...
Piotr Solnica
@solnic
wow wait, wdym by 'recreate predicate'?
Fran Worley
@fran-worley
When you call predicate.curry it intern calls Predicate.new passing in the curried version as the block
Therefore it's not enough to get the argument names on initialisation as calling block.parameters after it has been curried simply returns :rest not the actual parameters
Piotr Solnica
@solnic
ah shit
yeah that's what I'm talking about when I say that it'd be great to see MRI getting better FP features rather than some rails-inspired nonsenses
Gregory Huczynski
@greghuc
@solnic thanks for the code. Will start on API refactor with dry-validation and dry-type soon.
Piotr Solnica
@solnic
well, we have no other choice than to extend predicate with options and store needed data there
Fran Worley
@fran-worley
@solnic thats what I figured is it a significant performance hit?
Piotr Solnica
@solnic
shouldn't be, we're gonna have more stuff stored in predicates but we don't create predicate instances at runtime in dry-v so
won't affect it too much
the biggest perf gain we can get is to simplify error/hint compilers anyway
Fran Worley
@fran-worley
Ok cool. If you try and call an argument without having provided all args should it raise an error? I think at the moment it just fills the unknowns in with nil instead
Piotr Solnica
@solnic
we curry predicates when building rules for a schema, then it's just calling predicates with the remaining args
once you get the arity in, you can raise an error
this would be a good improvement, i thought about it already but didn't bother as I was focused more on dry-v
it even crossed my mind to make it auto-curry like in rom relations but thought I won't do it since I don't have an immediate use-case yet
Chris Richards
@cmrichards
Hey. Dry-validation will tell me if my form params are valid, but how would I then create an object representing the form that has attributes with the correct types?
Luca Guidi
@jodosha
@solnic @timriley @fran-worley @AMHOL @tak1n here's the PR that integrates dry-validation with hanami-validations: hanami/validations#100 :100: - It will land in master next week, the release will happen after dry-v 0.8. Thank you all for your support! :green_heart: :blue_heart: :yellow_heart:
Fran Worley
@fran-worley
@jodosha looks great! :thumbsup:
@timriley @solnic Any objections to merging dry-rb/dry-validation#155 into master ?
Luca Guidi
@jodosha
:)
Piotr Solnica
@solnic
@fran-worley looks good
Fran Worley
@fran-worley
@solnic I'd love to have your thoughts on this: dry-rb/dry-logic#13
Piotr Solnica
@solnic
I'll check it out later today, busy working atm
Fran Worley
@fran-worley
@solnic no worries, I have to say now that I actually understand how the gem works I love it even more. :smiley_cat: