var DefaultValidationKeys map[string]map[int]string
Register default validation keys for all calls to Controller.Validation.Func(). Map from (package).func => (line => name of first arg to Validation func) E.g. "myapp/controllers.helper" or "myapp/controllers.(*Application).Action" This is set on initialization in the generated main.go file.
func ValidationFilter(c *Controller, fc []Filter)
Revel Filter function to be hooked into the filter chain.
type Validation struct { Errors []*ValidationError // contains filtered or unexported fields }
A Validation context manages data validation and error messages.
func (v *Validation) Check(obj interface{}, checks ...Validator) *ValidationResult
Apply a group of validators to a field, in order, and return the ValidationResult from the first one that fails, or the last one that succeeds.
func (v *Validation) Clear()
Clear *all* ValidationErrors
func (v *Validation) Email(str string) *ValidationResult
func (v *Validation) Error(message string, args ...interface{}) *ValidationResult
Error adds an error to the validation context.
func (v *Validation) ErrorMap() map[string]*ValidationError
ErrorMap returns the errors mapped by key. If there are multiple validation errors associated with a single key, the first one "wins". (Typically the first validation will be the more basic).
func (v *Validation) HasErrors() bool
HasErrors returns true if there are any (ie > 0) errors. False otherwise.
func (v *Validation) Keep()
Keep tells revel to set a flash cookie on the client to make the validation errors available for the next request. This is helpful when redirecting the client after the validation failed. It is good practice to always redirect upon a HTTP POST request. Thus one should use this method when HTTP POST validation failed and redirect the user back to the form.
func (v *Validation) Length(obj interface{}, n int) *ValidationResult
func (v *Validation) Match(str string, regex *regexp.Regexp) *ValidationResult
func (v *Validation) Max(n int, max int) *ValidationResult
func (v *Validation) MaxSize(obj interface{}, max int) *ValidationResult
func (v *Validation) Min(n int, min int) *ValidationResult
func (v *Validation) MinSize(obj interface{}, min int) *ValidationResult
func (v *Validation) Range(n, min, max int) *ValidationResult
func (v *Validation) Required(obj interface{}) *ValidationResult
Required tests that the argument is non-nil and non-empty (if string or list)
type ValidationError struct { Message, Key string }
Simple struct to store the Message & Key of a validation error
func (e *ValidationError) String() string
String returns the Message field of the ValidationError struct.
type ValidationResult struct { Error *ValidationError Ok bool }
A ValidationResult is returned from every validation method. It provides an indication of success, and a pointer to the Error (if any).
func (r *ValidationResult) Key(key string) *ValidationResult
Key sets the ValidationResult's Error "key" and returns itself for chaining
func (r *ValidationResult) Message(message string, args ...interface{}) *ValidationResult
Message sets the error message for a ValidationResult. Returns itself to allow chaining. Allows Sprintf() type calling with multiple parameters