Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var RegexpValidateEmailAddress = regexp.MustCompile(`^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$`)
RegexpValidateEmailAddress is just a very simple regular expression to catch 99% of user input mistakes. Email addresses in the system are always validated by actually sending a verification email to it.
var RegexpValidatePostalcode = regexp.MustCompile(`^[0-9]{4} ?[a-zA-Z]{2}$`)
RegexpValidatePostalcode can be used to validate a dutch postalcode (e.g. `1234AB`)
Functions ¶
This section is empty.
Types ¶
type APIResponse ¶
APIResponse is used by insert/update/delete methods to indicate to the frontend whether the operation was successful. When marshalled to JSON it will give the front-end an array of errors, length 0 indicating all went fine. And optionally the ID of a created object.
func NewAPIResponse ¶
func NewAPIResponse() APIResponse
NewAPIResponse creates a new emptry API response.
func (*APIResponse) AddErrorCode ¶
func (cr *APIResponse) AddErrorCode(err string)
AddErrorCode adds an error code to the APIResponse
func (*APIResponse) CheckPgErr ¶
func (cr *APIResponse) CheckPgErr(err error) bool
CheckPgErr checks an error. If it's a postgres error of a kind that is handled in the front-end, an error code is added to the API response object and the function returns true. TODO: accept a whitelist of database constraints and violations that can go through to the frontend.