Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Piotr Solnica
@solnic
actually, it’s probably a good idea to always ignore filled? failure when there are other rules, can’t think of any reason why you would want to display age cannot be blank + more info about other rules
Tim Riley
@timriley
Yeah.
Filip Bartuzi
@Bartuz
hello
Piotr Solnica
@solnic
hey ho
Filip Bartuzi
@Bartuz
have you already started working on i18n support? Is there dedicated branch for that?
Piotr Solnica
@solnic
not yet
Filip Bartuzi
@Bartuz
Ok, great. I would like to contribute
Piotr Solnica
@solnic
cool! I gotta clean up current error compiler and come up with some common interface so that buiding new compilers will be simple
we talked with @AMHOL that maybe it’s gonna be possible to only have Messages and its sub-classes for specific backends
so that we only have one compiler and it calls messages#lookup and passes all the info that might be needed to get a string message from some backend
Filip Bartuzi
@Bartuz
Piotr, you use dry-validation is rails based projects, right?
Piotr Solnica
@solnic
no, I don’t use it yet in anything ‘real'
I started using it in rodakase-blog sample app though
but nothing fancy yet
Filip Bartuzi
@Bartuz
I will appreciate any kind of example. I'll have a look on https://github.com/solnic/rodakase-blog later
Piotr Solnica
@solnic
@Bartuz what kind of examples?
Andy Holland
@AMHOL
@solnic nice work xD
What was the thinking with going with Schema#call(data).messages rather than just having Schema#call(data) return formatted messages?
Piotr Solnica
@solnic
@AMHOL you’re gonna need more info than just messages
errors vs hints etc
also, some people may want to take that and process further (ie in reform)
so I’m taking those use cases into consideration already
Andy Holland
@AMHOL
Ahh, OK, cool :)
Piotr Solnica
@solnic
@AMHOL mergy-mergy? :joy:
Hannes Nevalainen
@kwando
@solnic should one prefer call_sheet over transflow? Seems to be quite similar
Piotr Solnica
@solnic
I pushed i18n branch to dry-validation, gonna “prepare the ground” there, maybe add some super basic functionality too, happy to get some help later on with it /cc @AMHOL @Bartuz
lots of things to consider, so I’ll open a PR early so we could discuss in async mode too
Andy Holland
@AMHOL
@solnic not sure what you think, but we could avoid symbolize_keys by using :key: value in YAML files?
Piotr Solnica
@solnic
more typing in yaml, I think it’s valuable to simply convert to symbols, it’s not too complex
alternatively we could lookup by strings
Andy Holland
@AMHOL
That could work
Then we can use a namespace separator like in dry-container/i18n
Symbolize keys is complicated when it comes to nested arrays of hashes and stuff
Piotr Solnica
@solnic
I’ve NO IDEA how to use I18n
trying to figure it out from the API docs, w/o success
that’s just sad
Piotr Solnica
@solnic
def initialize
  @t = I18n.method(:t)
end

def lookup(predicate, arg)
  t.("errors.#{predicate}")
end
they see me callin, they hatin
Andy Holland
@AMHOL
:joy:
Piotr Solnica
@solnic
ok, I got it working, the same functionality is covered as with the built-in YAML messages
I need to…dry it up
there’s a bit of common, abstract functionality there
one interesting thing is that it is possible to provide error compiler that will convert our error representation to an AM-compatible structure so that in theory existing AM-based error message translations will work with it
ain’t gonna do it, just saying it’s possible ;)
Andy Holland
@AMHOL
:laughing:
Piotr Solnica
@solnic
Calculating -------------------------------------
ActiveModel::Validations
                       143.000  i/100ms
      dry-validation   927.000  i/100ms
-------------------------------------------------
ActiveModel::Validations
                          1.495k (± 7.3%) i/s -      7.579k
      dry-validation      9.429k (± 1.6%) i/s -     47.277k

Comparison:
      dry-validation:     9428.8 i/s
ActiveModel::Validations:     1494.6 i/s - 6.31x slower
this is AM+I18n-coercions vs dry-validation+I18n+coercions
Andy Holland
@AMHOL
:clap:
@solnic out of interest, how come you did class Messages::I18n rather than the usual nesting?
Piotr Solnica
@solnic
I really don’t know