Skip to content

Instantly share code, notes, and snippets.

@unscriptable
Created October 21, 2016 15:28
Show Gist options
  • Save unscriptable/189e013cdfec2dcee0f95deea6f7a409 to your computer and use it in GitHub Desktop.
Save unscriptable/189e013cdfec2dcee0f95deea6f7a409 to your computer and use it in GitHub Desktop.
Code snippet used in an IoC blog post
import _ from "lodash"
export const smsMessage = (template, isValidPhone) => {
const createMessage = _.template(template)
const validate = throwIfInvalidPhone(isValidPhone)
return _.compose(validate, createMessage)
}
const throwIfInvalidPhone = isValidPhone => user => {
if (!isValidPhone(user.phone)) {
throw new Error(`Invalid phone for user ${ user.id }.`);
}
return user
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy