2018-12-04 21:58:38 +00:00
|
|
|
import { capitalize } from 'lodash'
|
2018-12-03 18:43:58 +00:00
|
|
|
|
|
|
|
export function humanizeErrors (errors) {
|
2018-12-04 21:58:38 +00:00
|
|
|
return Object.entries(errors).reduce((errs, [k, val]) => {
|
|
|
|
let message = val.reduce((acc, message) => {
|
2018-12-03 18:43:58 +00:00
|
|
|
let key = capitalize(k.replace(/_/g, ' '))
|
|
|
|
return acc + [key, message].join(' ') + '. '
|
|
|
|
}, '')
|
|
|
|
return [...errs, message]
|
|
|
|
}, [])
|
|
|
|
}
|
2019-04-10 18:48:42 +00:00
|
|
|
|