Add validation error info to DOC

pull/169/head
joeybloggs 9 years ago
parent 19b2f07d98
commit d792c5a578
  1. 10
      doc.go

@ -16,6 +16,16 @@ I needed to know the field and what validation failed so that I could provide an
return "Translated string based on field" return "Translated string based on field"
} }
Validation functions return type error
They return type error to avoid the issue discussed in the following, where err is always != nil:
http://stackoverflow.com/a/29138676/3158232
https://github.com/bluesuncorp/validator/issues/134
validator only returns nil or ValidationErrors as type error; so in you code all you need to do
is check if the error returned is not nil, and if it's not type cast it to type ValidationErrors
like so err.(validator.ValidationErrors)
Custom Functions Custom Functions
Custom functions can be added Custom functions can be added

Loading…
Cancel
Save