Skip to content

Instantly share code, notes, and snippets.

View albertossilva's full-sized avatar
🤹‍♂️

Alberto albertossilva

🤹‍♂️
View GitHub Profile

Keybase proof

I hereby claim:

  • I am albertossilva on github.
  • I am albertossilva (https://keybase.io/albertossilva) on keybase.
  • I have a public key ASCd3ZGPeYjLkM469c3qNUDehQESwnsJkm0KPp0gwLMlSAo

To claim this, I am signing this object:

@albertossilva
albertossilva / validators.js
Created January 1, 2017 15:26
Validating an object without 'if's
const validEmptyField = ({ field, label }) => ({
match: (data) => {
const value = data && data[field]
return value === null || value === undefined || (typeof value === 'string' && value === '')
},
message: () => `${label} is required`
})
const validEmailConfirmation = {
match: ({ email, confirmationEmail }) => email && email !== confirmationEmail,
console.log('You have been hacked!');
console.log('Sample')