These are chat archives for dry-rb/chat

3rd
Aug 2017
Oskar Szrajer
@gotar
Aug 03 2017 13:40
@mensfeld not entairly sure, do not remmember how was the correct way to do it, but for me each do not fire for empty array, so you need extra predicate before, like :min_size?: 1 or so
to check is the topics possess any element
(each just check is it array?) do not check anything related to size
Maciej Mensfeld
@mensfeld
Aug 03 2017 14:08
@gotar thanks @solnic helped already :)
Oskar Szrajer
@gotar
Aug 03 2017 14:38
ok ;] will be good to put this to doc (on page), it's 2nd, or 3rd person who ask about this
looks like it's a common problem
Sean Collins
@cllns
Aug 03 2017 15:46

How do y'all recommend pulling Form schemas out into their own file? http://dry-rb.org/gems/dry-validation/reusing-schemas/ says:

UserSchema = Dry::Validation.Schema do
  required(:email).filled
  required(:name).filled
  required(:address).schema(AddressSchema)
end

But something like this is more natural to me:

class UserSchema < Dry::Validation.Schema 
  # doesn't work, just showing syntax
  schema do
    required(:email).filled
    required(:name).filled
    required(:address).schema(AddressSchema)
  end
end
Sean Collins
@cllns
Aug 03 2017 15:58
open to the UserSchema = way, it just feels less natural to me :)
Gustavo Caso
@GustavoCaso
Aug 03 2017 16:01
An even less complicated example
Sean Collins
@cllns
Aug 03 2017 16:11
thanks! that's better :) @gotar @GustavoCaso
Gustavo Caso
@GustavoCaso
Aug 03 2017 16:11
np @cllns