Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 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
  • Oct 21 17:19
    ekremkaraca starred dry-rb/dry-configurable
  • Oct 21 13:32
    flash-gordon commented #361
Ralf Schmitz Bongiolo
@mrbongiolo
@fran-worley in the latest version it "kinds" of work, but the error compilers fails with: dry-rb/dry-validation#217
instead of sending the list argument, it uses list_left and list_right
Piotr Solnica
@solnic
right, that’s our breaking change (it’s in changelog)
Fran Worley
@fran-worley
We convert message tokens automatically based on the type of value. A range is converted to _left and _right and an array is converted to a comma separated string. The idea is to make a 'pretty' string. Is this not what you want?
Ralf Schmitz Bongiolo
@mrbongiolo
But the key won't work for arrays and ranges then.
Fran Worley
@fran-worley
We need message types again like with size don't we...
Ralf Schmitz Bongiolo
@mrbongiolo
When an array is used, then the messages receives a list, when a range is used then it receives list_left and list_right, but the key to lookup is always the same: errors.included_in?
I guess so
changing my yml to this:
    included_in?:
      arg:
        default: "tamanho tem que ser %{list}"
        range: "tamanho tem que estar entre: %{list_left} - %{list_right}"
Fran Worley
@fran-worley
Any luck?
Ralf Schmitz Bongiolo
@mrbongiolo
yep, it worked
I'll update the default errors.yml and send a PR
Fran Worley
@fran-worley
Thanks can up change excluded_from aswell?
Ralf Schmitz Bongiolo
@mrbongiolo
ok
shouldn't we get rid of exclusion? and inclusion? keys already?
Fran Worley
@fran-worley
They have to stay as the predicates are just deprecated
I probably wouldn't bother updating them as people should just migrate to the new predicate names.
Ralf Schmitz Bongiolo
@mrbongiolo
Ok, no problem
Ralf Schmitz Bongiolo
@mrbongiolo
@solnic dynamic arguments doesn't work with rules?
Piotr Solnica
@solnic
@mrbongiolo you mean rule API?
Ralf Schmitz Bongiolo
@mrbongiolo
Yes @solnic
I was trying to use something like: rule() { year.gteq?(current_year) and having that current_year defined in the configure block, but it said that the it couldn't find the predicate
Piotr Solnica
@solnic
yes it’s not supported yet
Ralf Schmitz Bongiolo
@mrbongiolo
Ah ok
John Backus
@backus
@hectorsq thanks
Piotr Solnica
@solnic
@dsounded hey man, sorry for this late reply. Help is appreciated although I have to say that’s probably the worst task for a first contribution :) I’ll try to do it this Friday and hopefuly push a new release
Joe Van Dyk
@joevandyk
what’s the best way to validate a hash that looks like this? { id: 550, name: "Arts", child: { id: 123, name: "Prints", child: { … } } ?
Kevin Ross
@rosskevin

I'm trying to get a reusable schema initializer with my common options included, but can't quite get it right. Is there an easier option or can you spot the error in my syntax?

module Form
    module Validations
      require 'i18n'
      require 'dry-validation'

      def self.new_schema(options, &block)
        Dry::Validation.Schema(options) do
          configure do
            predicates(Predicates)
            config.messages = :i18n
          end

          yield(block)
        end
      end
    end
  end

yields NoMethodError: undefined method required for usage Validations.new_schema(build: false) { required(:user).filled(:str?) }

my yield foo is not the best
Kevin Ross
@rosskevin
Got it. Still wondering if there are better ways:
      def self.new_schema(options, &block)
        Dry::Validation.Schema(options) do
          configure do
            predicates(Predicates)
            config.messages = :i18n
          end

          instance_eval &block
        end
      end
Piotr Solnica
@solnic
@rosskevin just define a class set it up and pass it to Schema() constructor function
Kevin Ross
@rosskevin
great, thanks!
John Backus
@backus
Wrote up a pretty comprehensive post on new features in Ruby 2.4: https://blog.blockscore.com/new-features-in-ruby-2-4/
Not related to dry-rb but I wanted to share with people here
Piotr Solnica
@solnic
@backus thanks for sharing. Very nice write up
Folks at work shared it too today and I was like "hey I know the author!" :)
Fran Worley
@fran-worley
@backus thanks, your post is very clear and well written. Sounds like there's some really good stuff in there.
Andy Holland
@AMHOL
Enumerable#sum, fantastic :laughing:
John Backus
@backus
@solnic @fran-worley thanks! I'm glad you liked it
@AMHOL I'm predicting now that this will result in some rails-core vs. ruby-core conflict :smile: :worried:
Ruby core developer opening an issue saying ActiveSupport should change their implementation: rails/rails#24796
Rails contributor (schneems) asking ruby core to try to match ActiveSupport's implementation: https://bugs.ruby-lang.org/issues/12217#note-9
yikes
Piotr Solnica
@solnic
Well, enum#sum is not a good idea in general since enumerable is a pretty wide interface
John Backus
@backus
I think it seems fairly reasonable
The actual ruby core thread is basically like
We grepped through a ton of ruby gems and .inject(:+) is heavily used
might as well add #sum
Andy Holland
@AMHOL
@backus :joy: