houdini/client/js/common/ff-form-validation/lib/readable-prop.es6

11 lines
235 B
JavaScript

// "email_address" => "email address"
// "emailAddress" => "email address"
module.exports = str =>
str
.replace('_', ' ')
.replace(/([a-z])([A-Z])/g, '$1 $2')
.replace(/\b([A-Z]+)([A-Z])([a-z])/, '$1 $2$3')
.toLowerCase()