Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Krzysztof Wawer
@wafcio
thanks for help
Andy Holland
@AMHOL
NP
Krzysztof Wawer
@wafcio
I am creating console ruby app with dry-system and some features are missing, which exist in dry-web. dry-web shouldn't be small wrapper with rack, monitoring stuff, which easly allow to create web app ? Am I correct or not ?
Pablo Herrero
@pabloh
Where can you find some documentation about defining custom types with coercion to use with dry-validation?
Don Morrison
@elskwid
@pabloh I went looking for this the other day and ended up digging around in rom-sql since there are custom types built for postgres (for example)
Andy Holland
@AMHOL
@wafcio if it's useful for a console app then it should probably be in dry-system
Krzysztof Wawer
@wafcio
@AMHOL should I create new topic about it on forum ?
Piotr Solnica
@solnic
Just report an issue
John Backus
@backus
@solnic thoughts on adding something like Dry::Types::Type which all type definitions inherit from? Seems like it would make dry types a bit easier to work with if all type definitions === Dry::Types::Type
blob
Not exactly true right now
(would also make the docs simpler :laughing: I'm currently trying to improve them even though they are already quite thorough)
Tim Riley
@timriley
@AMHOL Do you reckon you might be able to start a CHANGELOG.md for dry-configurable? :pray: :angel:
Oskar Szrajer
@gotar
hmm what happens with dry-fixtures? I was sure it was added some time ago to dry family , but cannot find it anywhere.
Tim Riley
@timriley
@gotar I don't think we had it. You might be interested in rom-factory though
Oskar Szrajer
@gotar
ah yes my mistake, I was searching for rom-factory ;]
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