strings.js.coffee - noiseunion/do-toolbox GitHub Wiki
Collection of String methods
capitalize(str)
Capitalize first character of a string
Params
str
- string you wish to have titled
titleize(str)
Capitalize first character of each word of a string
Params
str
- string you wish to have titled
formatJSONErrors(str [, withKeys])
Takes a JSON object and convert it to a readable sentence
Params
str
- JSON string or plain objectwithKeys
- Boolean - should returned array contains keys
Example
json = {
email: ["must be at least 6 characters", "must contain a number and a letter"]
}
withoutKeys = window.utilityBox.formatJSONErrors(json)
withKeys = window.utilityBox.formatJSONErrors(json, true)
Outputs
withoutKeys: ["email must be at least 6 characters and must contain a number and a letter"]
withKeys: [{email: "email must be at least 6 characters and must contain a number and a letter"}]