-
Notifications
You must be signed in to change notification settings - Fork 0
lodash
Yongku cho edited this page Apr 4, 2018
·
1 revision
// Data
const people = [
{
name: 'peter',
address: 'Seoul',
phone: '01012341234'
},
{
name: 'hacker',
address: 44444,
phone: '01012345678'
},
{
name: 'hacker',
address: 'hacker',
phone: 'undefined'
}
]
// Function
const removeSnake = _.partial(_.replace, _, /\-/g)
const validate = _.conforms({
name: _.isString,
address: _.isString,
phone: _.flow([removeSnake, _.parseInt, _.isInteger])
})
// Result
const result = _.map(people, validate)
// [true, false, false]