Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am maribies on github.
  • I am maribies (https://keybase.io/maribies) on keybase.
  • I have a public key ASDKh9-8q5DdH162IHuUqWIQYCrPVBFwl8zP2DRhujXqvgo

To claim this, I am signing this object:

@maribies
maribies / explore.rb
Created May 8, 2021 14:24
Explorations of validations in Ruby using Seeing is Believing
required = [:sender, :recipient, :amount]
test1 = {sender: 'me', recipient: 'you', amount: 1}
test2 = {sender: '', recipient: '', amount: ''}
test3 = {sender: 'me', recipient: '', amount: 1}
'Missing values' if required.all? { |k| test1.key? k } # => "Missing values"
'Missing values' unless required.all? { |k| test1.key? k } # => nil
'Missing values' if test1.values.include? '' && required.all? { |k| test1.key? k } # => nil
'Missing values' unless test1.values.include? '' && required.all? { |k| test1.key? k } # => "Missing values"
### Keybase proof
I hereby claim:
* I am maribies on github.
* I am maribies (https://keybase.io/maribies) on keybase.
* I have a public key ASBojbnPhZu_L29adgK_uzhFCAsszAb593d8oeh6csBVVAo
To claim this, I am signing this object: