Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Dec 12 21:34
    flash-gordon commented #376
  • Dec 12 21:34
    flash-gordon labeled #376
  • Dec 12 21:34
    flash-gordon opened #376
  • Dec 12 19:32
    RyanLafferty starred dry-rb/dry-types
  • Dec 12 05:53
    technofreak starred dry-rb/dry-monads
  • Dec 12 00:14
    thekuwayama starred dry-rb/dry-monads
  • Dec 11 09:29
    blasterun starred dry-rb/dry-monads
  • Dec 11 08:34
    flash-gordon closed #115
  • Dec 11 08:34
    flash-gordon commented #115
  • Dec 11 08:31

    flash-gordon on v1.3.3

    (compare)

  • Dec 11 08:30

    flash-gordon on master

    Bump version to 1.3.3 (compare)

  • Dec 11 08:30

    flash-gordon on master

    Update CHANGELOG (compare)

  • Dec 10 23:46
    johnmaxwell commented #116
  • Dec 10 21:54

    flash-gordon on master

    Halt with mutable backtrace Ex… Merge pull request #116 from jo… (compare)

  • Dec 10 21:54
    flash-gordon closed #116
  • Dec 10 21:54
    flash-gordon commented #116
  • Dec 10 21:49
    johnmaxwell commented #116
  • Dec 10 21:47
    johnmaxwell commented #116
  • Dec 10 21:43
    johnmaxwell commented #116
  • Dec 10 21:39
    johnmaxwell commented #116
Rafael George
@cored
the good old force push
Piotr Solnica
@solnic
just hard reset to master
Rafael George
@cored
ok I'll do that then
Piotr Solnica
@solnic
and -f push
Kiril Dokh
@dsounded
@solnic Have you taken a look at issue ?
Piotr Solnica
@solnic
@dsounded I did, tbh I didn’t have an immediate idea how this should be done, since it’s a single rule, that is used against multiple values, so I’ve no idea how error messages should be created for this
Kiril Dokh
@dsounded
That’s why I thought about something like :base in Rails validation
So we can store errors like this there
Because this error doesn’t belong to one field, but to couple
Piotr Solnica
@solnic
right, maybe we should add it under rule’s name then?
Kiril Dokh
@dsounded
Makes sense
Piotr Solnica
@solnic
that’s how it used to work btw, but I didn’t like it since for more common cases it was just weird
Kiril Dokh
@dsounded
Hmm, maybe it looks like this, but I do believe it can be repeated in future
Anyway, it’s up to you, I just want somehow this to be able to implement :)
Piotr Solnica
@solnic
well, I was planning to add ability to execute arbitrary validation blocks that are still guarded
but it’d be up to you how to implement it and you’d have to return a result object explicitly
I might be able to do that quickly before 0.10.0
Fran Worley
@fran-worley

@solnic I'm getting a warning (warning: too many arguments for format string) coming through from here:
https://github.com/dry-rb/dry-validation/blob/master/lib/dry/validation/message_compiler.rb#L151

Should we check that there are the correct tokens for the string?

Piotr Solnica
@solnic
@fran-worley oh haven’t thought about that
I guess we should
I didn’t even know this produces a warning :)
Fran Worley
@fran-worley
Yeah, I didn't either. TBF it makes sense when you think about it. Annoying though as we always provide more tokens than are actually used
Piotr Solnica
@solnic
we’d have to parse messages and store info about their tokens
we don’t want to do it all over again during message compilation
Fran Worley
@fran-worley
Yeah adding more overhead especially for valid runs
I've also got these coming through:
dry-validation-0.9.5/lib/dry/validation/schema/value.rb:42: warning: method redefined; discarding old schema
dry-types-0.8.1/lib/dry/types/options.rb:18: warning: method redefined; discarding old meta
dry-types-0.8.1/lib/dry/types/struct/class_interface.rb:65: warning: instance variable @schema not initialized
dry-types-0.8.1/lib/dry/types/struct/class_interface.rb:59: warning: instance variable @constructor_type not
But the messages one is the worst as it comes through for every single message. I know I could just turn warnings of but :monkey_face:
Piotr Solnica
@solnic
I thought we fixed those warnings in dry-struct
Fran Worley
@fran-worley
Possibly thats coming through form old dry-types
Piotr Solnica
@solnic
oh right
Piotr Solnica
@solnic
@fran-worley just added support for arbitrary validation blocks: dry-rb/dry-validation@8922ac0
@dsounded ^^ this will make things simpler for you, but I still need to figure out a way for defining that error message should be attached to something else than the last attribute name in the list of rule deps
ie right now doing validate(foo?: [:bar, :baz, :foo]) { … } will attach error messages to :foo key (the last dependency)
Fran Worley
@fran-worley
@solnic what's the difference between these and high level rules?
My end goal is to be able to essentially validate X schema if Y schema passes
Piotr Solnica
@solnic
@fran-worley this allows arbitrary code
and it’s executed in the context of the schema object
so self in this block is a schema
Fran Worley
@fran-worley
So in theory you could make another validate block a dependency ?
Piotr Solnica
@solnic
yes, I always wanted to support that
but first I need to figure out how to identify them and how to enforce error key so that it doesn’t default to the last dep name
Fran Worley
@fran-worley
validate :simple_checks do
  required(:email).filled(:str?)
  required(:name).filled(:str?)
  required(:birthday).filled(:date?)
end

# only run this group if our simple_checks pass
validate advanced_checks: :simple_checks do
  # not sure how you could append to an existing key. 
  # In theory we don't need to check that the key exists any-more as we've already done that.
  value(:email) { valid_email?  & unique_email? }
  value(:birthday) { gt?(some_date) }
end
Piotr Solnica
@solnic
what’s the reason for grouping here?
Fran Worley
@fran-worley
I split my validations up into existence/ type/ format checks vs more complex database reliant checks like existence or permissions. That way if the simple ones fail, I don't bother going any further
However I might have simple checks on all fields in my form which could have dozens of fields so declaring each one as a dependency would be a PITA
Piotr Solnica
@solnic
but that makes entire group of rules depend on other groups of rules, so ie failing basic check for :name will prevent :email which is completely unrelated to :name
Fran Worley
@fran-worley
I want to start by validating that email, name and birthday exist and are the correct data type. If that group passes then I want to validate some other things which could involve hitting the database etc. If it doesn't then I'll just return the errors back to the user for them to try again.
I usually only split database checks, or safe guards against HTML form hacking (i.e. checking the my user has the right to link to that record) so hints on these rules are a bit irrelevant.
Kiril Dokh
@dsounded
@solnic I do appreciate your job
Fran Worley
@fran-worley
@dsounded he's a bit of a :star2: really. I'm not sure how you find the time @solnic between a job, family and sleep!
Aditya Tiwari
@aditya01933
i want to create schema mix of array and normal param. something like this
PurchaseSchema = Dry::Validation.Schema do 
  each do 
    schema do
      required(:line_item_id).filled
      required(:quantity).filled
    end
  end
  required(:account_id).filled
  required(:stripe_customer_id).filled
end