Skip to content

Commit

Permalink
String() helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek Dowling committed Dec 17, 2015
1 parent 28c960e commit ea63c83
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions object.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ func (o *Object) Prepare(r *http.Request, response bool) (*Response, *Error) {
return &Response{HTTPStatus: status, Data: o}, nil
}

// String prints a formatted string representation of the object
func (o *Object) String() string {
raw, err := json.MarshalIndent(o, "", " ")
if err != nil {
return err.Error()
}

return string(raw)
}

// validateInput runs go-validator on each attribute on the struct and returns all
// errors that it picks up
func validateInput(target interface{}) *Error {
Expand Down

0 comments on commit ea63c83

Please sign in to comment.