Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Piotr Solnica
@solnic
@jodosha grab rom-repo from master then and look at latest specs, these are pretty high-level tests so should give you an overview of what’s possible
Luca Guidi
@jodosha
@solnic thank you! :)
Piotr Solnica
@solnic
I was going to add a bin/console to rom-repo but ran out of time
basically to have the same setup as we have in specs loaded for you so it’s easy to open console and do stuff
The last two are quite old
Damn, forgot that Gitter would expand those, sorry for the flood :(
Luca Guidi
@jodosha
@AMHOL Thank you! :green_heart:
Andy Holland
@AMHOL
:+1:
Piotr Solnica
@solnic
@jodosha do you have any ideas what kind of integration you’d want to have?
Luca Guidi
@jodosha
@solnic My goals are: remove boilerplate as much as possible, SQL automapping, associations and command/queries.
Andy Holland
@AMHOL
@jodosha you're in luck then, it's all supported already
Luca Guidi
@jodosha
@AMHOL ;)
Piotr Solnica
@solnic
@jodosha do you like to provide mixins in a similar way like with validations?
Luca Guidi
@jodosha
@AMHOL @solnic yes, for instance, I will probably make this https://gist.github.com/AMHOL/83796ede7e3e3219c6f6c934823dfd3e#file-rom-repo-starter-rb-L29-L45 to happen behind the scenes
Piotr Solnica
@solnic
yep, I think getting setup in place would be a good first step
Andy Holland
@AMHOL
@jodosha would that mean exposing a generalised querying API via relation? That kind of defeats the object of the relation being there
Piotr Solnica
@solnic
ie provide config API for hanami-model where you set connection options and then it would set up ROM behind the scenes
Andy Holland
@AMHOL
The relation should make use of the dataset API to expose a domain specific query interface
Piotr Solnica
@solnic
it should also auto-require relations and optional custom mappers and commands
Andy Holland
@AMHOL
:+1: That works
Luca Guidi
@jodosha
@solnic yes
Andy Holland
@AMHOL
@solnic could this just be a plugin for rom-sql?
Piotr Solnica
@solnic
nah, it’s all there already in rom core, it’s a matter of configuring it
Andy Holland
@AMHOL
Ahh OK
Luca Guidi
@jodosha
@solnic @AMHOL I'll probably ask questions on specific topics. ;)
Andy Holland
@AMHOL
Cool :)
Piotr Solnica
@solnic
@jodosha let’s chat in rom-rb room, I’m there
Luca Guidi
@jodosha
:+1:
Piotr Solnica
@solnic
Andrew Kozin
@nepalez
@timriley I've made last 3 commits (at various times) directly to master
Aditya Tiwari
@aditya01933
Hi, I have a small question.
How can I remove code duplication in following Schemas:
Ahh .. I don't know how to paste code block in gitter
Piotr Solnica
@solnic
@aditya01933 use triple `
like that:
\`\`\`
your code
\`\`\`
Aditya Tiwari
@aditya01933
require 'dry-validation'
UserSchema = Dry::Validation.Schema do

  key(:username).required(:unique?)
  key(:name).required
  key(:email).required
  key(:password).confirm
  configure do
      config.messages_file = 'config/validations/errors.yml'
      config.input_processor = :sanitizer
     def unique?(value)
         User.find_by(username: value).nil?  
     end
  end
end
UserUpdateSchema = Dry::Validation.Schema do

  optional(:username).required(:unique?)
  optional(:name).required
  configure do
   config.messages_file = 'config/validations/errors.yml'
   config.input_processor = :sanitizer
    def unique?(value)
       User.find_by(username: value).nil?
    end
  end
end
Piotr Solnica
@solnic
oh well
Aditya Tiwari
@aditya01933
@solnic its not perfect but better
Any solution please ???
I want to remove code duplication of configuration block and "unique" custom predicate
Piotr Solnica
@solnic
class MySchema < Dry::Validation::Schema
  configure do |config|
    config.messages = :i18n
  end

  def unique?(value)
    false
  end

  def self.define(&block)
    Dry::Validation.Schema(self, &block)
  end
end

UserSchema = MySchema.define do
  key(:email).required(:unique?)
  key(:name).required
end
@aditya01933 like that ^
Aditya Tiwari
@aditya01933
@sonic Perfect!!!!!
Thanks its exactly what i was looking for :)
Piotr Solnica
@solnic
cool :)
Aditya Tiwari
@aditya01933
@solnic one more small question..
Currently i m testing uniqueness of username like
 def unique?(value)
      User.find_by(username: value)
  end
How can i write unique? in such a way that it can test uniqueness of other keys like name, email etc too ...
?
Piotr Solnica
@solnic
there’s no built-in conveniences for this type of predicates yet
you could parameterize it for now