gopkg.in/go-playground/validator.v7 (go): Package validator implements value validations for structs and individual fields based on tags. It can also handle Cross Field and Cross Struct validation for nested structs and has the ability to dive into arrays and maps of any type.  Why not a better error message? because this library intends for you to handle your own error messages.  Why should I handle my own errors? Many reasons, for us building an internationalized application I needed to know the field and what validation failed so that I could provide an error in the users specific language.  Custom functions can be added  Cross Field Validation can be done via the following tags: eqfield, nefield, gtfield, gtefield, ltfield, ltefield, eqcsfield, necsfield, gtcsfield, ftecsfield, ltcsfield and ltecsfield. If however some custom cross field validation is required, it can be done using a custom validation.  Why not just have cross fields validation tags i.e. only eqcsfield and not eqfield; the reason is efficiency, if you want to check a field within the same struct eqfield only has to find the field on the same struct, 1 level; but if we used eqcsfield it could be multiple levels down.  Multiple validators on a field will process in the order defined  Bad Validator definitions are not handled by the library  NOTE: Baked In Cross field validation only compares fields on the same struct, if cross field + cross struct validation is needed your own custom validator should be implemented.  NOTE2: comma is the default separator of validation tags, if you wish to have a comma included within the parameter i.e. excludesall=, you will need to use the UTF-8 hex representation 0x2C, which is replaced in the code as a comma, so the above will become excludesall=0x2C  NOTE3: pipe is the default separator of or validation tags, if you wish to have a pipe included within the parameter i.e. excludesall=| you will need to use the UTF-8 hex representation 0x7C, which is replaced in the code as a pipe, so the above will become excludesall=0x7C  Here is a list of the current built in validators:  Validator notes:  This package panics when bad input is provided, this is by design, bad code like that should not make it to production.
Keywords: error-handling|translation|validation