Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 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
  • Dec 10 21:31
    johnmaxwell commented #116
  • Dec 10 21:22
    flash-gordon commented #116
  • Dec 10 19:41
    johnmaxwell opened #116
  • Dec 10 19:36
  • Dec 10 10:24
    krautcat starred dry-rb/dry-view
Oskar Szrajer
@gotar
thx
Andy Holland
@AMHOL
@timriley sure
Pablo Herrero
@pabloh
Is there an easy way to customize how dates and date_time attributes ares parsed from strings by the forms?
Nikita Shilnikov
@flash-gordon
@pabloh you can build a custom type for that. Time.constructor { ... }
Pablo Herrero
@pabloh
@flash-gordon, and then you can just use it like this?:
CustomType = Time.constructor { ... }

Dry::Validation.Form do
  required(:date).filled(type?: CustomType)
end
Nikita Shilnikov
@flash-gordon
@pabloh I'm not sure if type? will work, there are some issues with using custom types IIRC
    to_time = -> x { Time.iso8601("#{x}Z") }
    ISOTime = Types::Strict::Time.constructor(to_time)

    Schema = Dry::Validation.JSON do
      optional(:sent_at, :time).value(ISOTime)
...
that's what I have^
Pablo Herrero
@pabloh
@flash-gordon , why do you need the second argument at optional?
can you not just do optional(:sent_at) { time? | value(ISOTime) }?
Nikita Shilnikov
@flash-gordon
@pabloh the second argument is for type_specs, i.e. specifies value type, as far as I know dry-v atm can work without it, but slower
just test^ I dunno, not an expert here lol
Pablo Herrero
@pabloh
hehe, I was trying... Dry::Types::Strict::Time did not work for some reason...
Nikita Shilnikov
@flash-gordon
@pabloh mb related dry-rb/dry-validation#223
Pablo Herrero
@pabloh
mmm...
Joakim Repomaa
@repomaa
hi, just want to point out that the link to hanami is broken
on the dry-types page
it links to https://hanamirb.org
which uses github's cert
you can only use http
Nikita Shilnikov
@flash-gordon
@jreinert thx, fixed
Joakim Repomaa
@repomaa
@flash-gordon nice! That was quick!
Loïc Guitaut
@Flink
Hey there! Do you know if it’s possible to raise (or report) errors on unknown parameters with dry-validation?
I didn’t see how to do this in the documentation
Loïc Guitaut
@Flink
nvm found a way to do something similar with another approach
Ben Moskovitz
@moskyb
Hey all, I'm having some trouble with dry-validation

I've found that, at least in my specific case,

each do
  schema do
    #some schema here
  end
end

is not equivalent to

FunSchema = Dry::Validation.Schema do
  # some schema here
end

# ... another schema
each do
  schema(FunSchema)
end
Philip Arndt
@parndt
This message was deleted
Ben Moskovitz
@moskyb
For reference, what I currently have is
PredefinedSchema = Dry::Validation.Schema do
  required(:audience).filled(:str?)
end

ComparisonSchema = Dry::Validation.Schema do
  %i(lt gt lte gte).each do |key|
    optional(key).maybe { int? | float? | time? }
  end
end

ParamSchema = Dry::Validation.Schema do
  required(:to) do
    str? & eql?('*') | schema(PredefinedSchema) | each do
      schema do
        required(:name).filled(:str?)
        required(:criteria).each do
          str? | int? | float? | time? | schema(ComparisonSchema)
        end
      end
    end
  end
end
And what I'd like to have is
CriterionSchema = Dry::Validation.Schema do
  required(:name).filled(:str?)
  required(:criteria).each do
    str? | int? | float? | time? | schema(ComparisonSchema)
  end
end

ParamSchema = Dry::Validation.Schema do
  required(:to) do
    str? & eql?('*') | schema(PredefinedSchema) | each do
      schema(CriterionSchema)
    end
  end
end
I understand that my use case here is kinda complex
Refactoring is fun
Nicolas Cavigneaux
@Bounga
Hi! I'm reading the doc for custom error messages and found something not working: Dry::Validation::Messages.load('/path/to/our/errors.yml') doesn't work since load is a private method
Nikita Shilnikov
@flash-gordon
@Bounga try Dry::Validation::Messages::YAML.load, looks like a mistake in docs
Nicolas Cavigneaux
@Bounga
Yes it works that what I've used but I just wanted to let you know about this mistake
Nikita Shilnikov
@flash-gordon
kk, I'll fix that, thanks
Nicolas Cavigneaux
@Bounga
BTW the YAML.load expect an array
Nicolas Cavigneaux
@Bounga
@flash-gordon You're fast!
Now there's another issue. user_messages[:filled?, rule: :address] returns nil not the provided custom message
I do think that nested rules are broken
Nicolas Cavigneaux
@Bounga

oh no, the example is wrong. It should no be nested in another rules.

en:
  errors:
    rules:

      user:
        filled?: "name cannot be blank"

        rules:
          address:
            filled?: "You gotta tell us where you live"

should be

en:
  errors:

    rules:

      user:
        filled?: "name cannot be blank"
        address:
            filled?: "You gotta tell us where you live"
Nicolas Cavigneaux
@Bounga
I already noticed that the doc is pretty outdated and contains many mistakes. Would you need some help to update it?
Nikita Shilnikov
@flash-gordon
@Bounga ohh, help is always welcome :) Though I can since 1.0 is coming I'm not sure how the docs should look like, better wait for @solnic to comment on this
re rules, I'm not sure about this, I'll have a look a bit later, busy atm
Nicolas Cavigneaux
@Bounga
np
Nikita Shilnikov
@flash-gordon
@Bounga current example works for me
messages = Dry::Validation::Messages::YAML.load(['/tmp/errors.yml'])
user_messages = messages.namespaced(:user)
user_messages[:filled?, rule: :address] # => "You gotta tell us where you live"
Pablo Herrero
@pabloh
Hey guys, I was wondering if there was some draft for the new dry-v 1.0 API?
Tim Riley
@timriley
Nothing yet apart from the message on the discussion forum, @pabloh
Alex Heeton
@heeton
Why is there no Form::String type in dry-types? What's the logic behind that? (I'm guessing everything is a string already, and Form seems to be for coercion? Is that correct?)