From b4563c2cf653ad1a3ad91010d6af2165c7eb1f58 Mon Sep 17 00:00:00 2001 From: joeybloggs Date: Sun, 30 Aug 2015 20:56:59 -0400 Subject: [PATCH] Add alias docs + notes --- doc.go | 12 ++++++++++++ validator.go | 5 ++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/doc.go b/doc.go index 13bb66e..cc96f2d 100644 --- a/doc.go +++ b/doc.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 (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: regex diff --git a/validator.go b/validator.go index 1fbba26..7382aa9 100644 --- a/validator.go +++ b/validator.go @@ -189,7 +189,10 @@ func (v *Validate) RegisterCustomTypeFunc(fn CustomTypeFunc, types ...interface{ // RegisterAliasValidation registers a mapping of a single validationstag that // 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) { if len(v.config.aliasValidators) == 0 {