Skip to content
kagd edited this page Jan 10, 2013 · 1 revision

Collection of String methods

.titleize(str)

Titleize 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 object
  • withKeys - 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"}]