These are chat archives for dry-rb/chat

21st
Sep 2018
Igor Alexandrov
@igor-alexandrov
Sep 21 2018 07:41
Hi guys, does anybody know what to do with this: dry-rb/dry-validation#424
Piotr Solnica
@solnic
Sep 21 2018 07:55
@igor-alexandrov this won't be fixed until 1.0.0 :(
BTW - I'll probably ship dry-schema before dry-validation 1.0.0, it will cover many typical use cases of some dry-validation users
Piotr Solnica
@solnic
Sep 21 2018 08:05
also, coincidentally, I've been working on type specs in dry-schema recently, just one failing spec left to fix :)
Igor Alexandrov
@igor-alexandrov
Sep 21 2018 08:13
@solnic we are open to help you with dry-schema. Let's discuss this in private
Igor Alexandrov
@igor-alexandrov
Sep 21 2018 08:57
Regarding the problem above, is there a way to change input processor on base schema?
Igor Alexandrov
@igor-alexandrov
Sep 21 2018 09:46
Updated pull request to work with 0.12.2: dry-rb/dry-validation#425
@solnic, @flash-gordon don't you think that it is critical and should be merged?
Piotr Solnica
@solnic
Sep 21 2018 09:48
I'll take a look
Igor Alexandrov
@igor-alexandrov
Sep 21 2018 09:49
Thanks
Igor Alexandrov
@igor-alexandrov
Sep 21 2018 14:19
BridgeExperienceSchema = Dry::Validation.Params do
  configure do
    config.type_specs = true
  end

  required(:transaction_purpose, :string).filled(included_in?: Loan::TRANSACTION_PURPOSES)

  required(:properties).each do
    schema do
      optional(:repair_value, LendingOne::Types::Currency).maybe(:number?)

      optional(:construction_budget, LendingOne::Types::Currency).maybe(:number?)
      rule(construction_budget: [:transaction_purpose, :repair_value, :construction_budget]) do |transaction_purpose, repair_value, construction_budget|
        transaction_purpose.eql?('purchase') & repair_value.filled? & repair_value.gt?(0) > construction_budget.filled?
      end
    end
  end
end
In example above how can I validate construction_budget to be filled only if transaction_purpose is equal to 'purchase'?
Brian Suh
@bsuh
Sep 21 2018 17:54
I want to do some validation on a dynamically shaped hash instead of a hash with keys known ahead of time. Is there a way to check each key fits a regex format and apply some predicates on each value?
Igor Alexandrov
@igor-alexandrov
Sep 21 2018 20:45
@bsuh I don't think that it is possible
Grant Shangreaux
@gcentauri
Sep 21 2018 21:00
you might be able to figure something out using types, but it sounds somewhat dubious to me
Brian Suh
@bsuh
Sep 21 2018 21:07
i just ended up creating a custom predicate