Add alias docs + notes

pull/169/head
joeybloggs 9 years ago
parent a964f5384a
commit b4563c2cf6
  1. 12
      doc.go
  2. 5
      validator.go

@ -445,6 +445,18 @@ Here is a list of the current built in validators:
http://golang.org/src/net/mac.go?s=866:918#L29 http://golang.org/src/net/mac.go?s=866:918#L29
(Usage: mac) (Usage: mac)
Alias Validators and Tags
NOTE: when returning an error the tag returned in FieldError will be
the alias tag unless the dive tag is part of the alias; everything after the
dive tag is not reported as the alias tag. Also the ActualTag in the before case
will be the actual tag within the alias that failed.
Here is a list of the current built in alias tags:
iscolor
alias is "hexcolor|rgb|rgba|hsl|hsla" (Usage: iscolor)
Validator notes: Validator notes:
regex regex

@ -189,7 +189,10 @@ func (v *Validate) RegisterCustomTypeFunc(fn CustomTypeFunc, types ...interface{
// RegisterAliasValidation registers a mapping of a single validationstag that // RegisterAliasValidation registers a mapping of a single validationstag that
// defines a common or complex set of validation(s) to simplify adding validation // defines a common or complex set of validation(s) to simplify adding validation
// to structs. // to structs. NOTE: when returning an error the tag returned in FieldError will be
// the alias tag unless the dive tag is part of the alias; everything after the
// dive tag is not reported as the alias tag. Also the ActualTag in the before case
// will be the actual tag within the alias that failed.
func (v *Validate) RegisterAliasValidation(alias, tags string) { func (v *Validate) RegisterAliasValidation(alias, tags string) {
if len(v.config.aliasValidators) == 0 { if len(v.config.aliasValidators) == 0 {

Loading…
Cancel
Save