Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddRule ¶
AddRule register a validation rule. The rule will be usable in request validation by using the given rule name.
Type-dependent messages let you define a different message for numeric, string, arrays and files. The language entry used will be "validation.rules.rulename.type"
func GetFieldType ¶
func GetFieldType(value interface{}) string
GetFieldType returns the non-technical type of the given "value" interface. This is used by validation rules to know if the input data is a candidate for validation or not and is especially useful for type-dependent rules. - "numeric" if the value is an int, uint or a float - "string" if the value is a string - "array" if the value is a slice - "file" if the value is a slice of "filesystem.File" - "unsupported" otherwise
func RequireParametersCount ¶
RequireParametersCount checks if the given parameters slice has at least "count" elements. If this is not the case, panics.
Use this to make sure your validation rules are correctly used.
func SetPlaceholder ¶
func SetPlaceholder(placeholderName string, replacer Placeholder)
SetPlaceholder sets the replacer function for the given placeholder. If a placeholder with this name already exists, the latter will be overridden.
validation.SetPlaceholder("min", func(field string, rule string, parameters []string, language string) string { return parameters[0] // Replace ":min" by the first parameter in the rule definition })
Types ¶
type Errors ¶
Errors is a map of validation errors with the field name as a key.
type Placeholder ¶
Placeholder function defining a placeholder in a validation message. This function should return the value to replace the placeholder with.