by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 04 12:29
    flash-gordon commented #403
  • Aug 04 10:46
    adamransom commented #403
  • Aug 04 10:17
    solnic commented #403
  • Aug 04 10:03
    adamransom commented #403
  • Aug 04 09:42
    adamransom commented #403
  • Aug 04 09:39
    solnic commented #403
  • Aug 04 09:36
    adamransom commented #403
  • Aug 04 09:35
    adamransom commented #403
  • Aug 04 09:33
    solnic commented #403
  • Aug 04 09:29
    adamransom edited #403
  • Aug 04 09:27
    adamransom opened #403
  • Jul 31 07:02
    flash-gordon commented #130
  • Jul 31 04:56

    solnic on master

    Merge pull request #131 from da… (compare)

  • Jul 31 04:55

    solnic on release-1.3

    small grammar changes to improv… Merge pull request #131 from da… (compare)

  • Jul 31 04:55
    solnic closed #131
  • Jul 31 04:53

    solnic on release-0.8

    Merge pull request #30 from dav… (compare)

  • Jul 31 04:51

    solnic on master

    Added in missing word and missi… Merge pull request #30 from dav… (compare)

  • Jul 31 04:51
    solnic closed #30
  • Jul 31 04:51
    solnic edited #30
  • Jul 31 00:21
    davich opened #131
Nicolas Cavigneaux
@Bounga
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?)
Was also hoping someone could give some info behind error messages in dry-validation. Similar to @Bounga's post above, I hit some issues with high-level rule messages. Background here - https://discuss.dry-rb.org/t/difficulty-creating-error-messages-for-high-level-rules/238 - specifically I'm wondering about intended naming conventions for rules, and if this is just a case of the docs being out of sync.
Sergey Kukunin
@Kukunin
@flash-gordon do you know, that new dry-monads transforms dry-structs into hashes?
Nikita Shilnikov
@flash-gordon
Yep, I'll push a kinda fix later today, you can check out the branch in dry-monads meanwhile
Sergey Kukunin
@Kukunin
btw, those are really cool changes to API of monads
Nikita Shilnikov
@flash-gordon
Thanks, it took me a while :)
Sam Stickland
@samstickland
Is Types::Form::DateTime supposed to be able to parse multipart form values? i.e start_time(1i), start_time(2i) etc
Adam Davies
@adz
Not sure but I
Juanma Cervera
@jmcervera
G
Joe Van Dyk
@joevandyk
i have Status = Types::String.enum('draft', 'published', 'deleted'). What's the best way to use that in a validation rule?
i tried required(:status, Status) but that didn't seem to work
(i tried enabling type_specs as well)
Nikita Shilnikov
@flash-gordon
@joevandyk this what works for me
        Action = Types::Strict::String.enum(*%w[publish update])

        Schema = Dry::Validation.Form do
          configure do
            config.type_specs = true
          end

          required(:action, :string).filled(Action)
        end
Joe Van Dyk
@joevandyk
@flash-gordon thanks, that works
@flash-gordon say action is allowed to be nil or empty string, and if it is you want to default to 'publish'. how would you do that?
Nikita Shilnikov
@flash-gordon
dry-v doesn't handle defaults because it only validates data, so would go with { **defaults, **data }
Joe Van Dyk
@joevandyk
@flash-gordon i'm not familiar with that syntax :)
Nikita Shilnikov
@flash-gordon
ahh, yes, this time plain merge will work better
Joe Van Dyk
@joevandyk
i'm assuming there's a way to get dry-v to pre-process that sort of thing and set a default?
Nikita Shilnikov
@flash-gordon
well, didn't see that :) you can then check for nil in a constructor block, right?
Piotr Macuk
@macuk

Hi. First of all thank you for great dry-rb gems. Dry-v is awesome! :) I have a problem. I would like to build form schema where some fields are known and some other fields should be dynamically created. I thought that I use Form.with(custom_struct: custom_struct).(params) with option within configure block [like here: http://dry-rb.org/gems/dry-validation/custom-validation-blocks/] but it doesn't work. I cannot use custom_struct inside the schema definition:

Form = Dry::Validation.Form do
  configure do
    option :custom_struct
  end

  required(:name).filled(:str?)
  required(:surname).filled(:str?)

  optional(:custom).schema do
    # error: "undefined method `each' for #<UnboundMethod:0x007f91b9978608> (NoMethodError)"
    custom_struct.each do |element|
      required(element.name)
    end
  end
end

I've found this topic [https://discuss.dry-rb.org/t/build-dry-validations-dynamically/164] in the forum but need some examples. Could you help me somehow? Thanks!

Sergey Kukunin
@Kukunin
is there a way to inherit form schema? I found I can pass basic schema via constructor Dry::Validation.Form(BaseSchema), but it requires a class there
John Backus
@backus
I've been working on a tool for checking the correctness of YARD docs and I've been using Dry::Types as my sample library. Figured I would share here :P https://github.com/backus/yardcheck
I also use Dry::Types as an example in the readme
Nikita Shilnikov
@flash-gordon
wow
AWESOME
@backus :+1:
John Backus
@backus
:D
It has been something I've wanted for a long time haha
Every time a co-worker of mine is like "I don't like documentation because it goes stale"
I'm like why is there not a tool to check
Tool is still rough around the edges but it is already very useful
John Backus
@backus
Also I have a super pedantic branch I've been working on which fixes some of these documentation things I found while testing the tool
Will PR eventually
I suggested adding a Dry::Types::Type so that a ton of the params and returns didn't have to be like
# @return [Constrained, Definition, Sum, Safe]
Nikita Shilnikov
@flash-gordon
ahh, right, this makes sense
Joe Van Dyk
@joevandyk
How do you guys typically structure your interactors/use cases, entities/value objects, etc?