talira

govalidator

Validators and sanitizers for strings, structs and collections in Go

open sourceMITfree

govalidator is a Go package of validators and sanitizers for strings, numbers, slices, maps and structs, based on validator.js. It has functions such as IsEmail, IsURL and IsIP, struct validation driven by valid tags (with ValidateStruct and ValidateMap), sanitizers like WhiteList and ToString, helpers that map and filter slices, and custom validators registered by tag name.

Problems it solves

  • check that a string in my Go service is a valid email address, URL or IP
  • validate a Go struct's fields from tags before saving it
  • sanitize user input strings in Go without writing my own regexes

Features

  • string validators such as IsEmail, IsURL and IsIP
  • struct validation from valid tags
  • map validation against a template
  • sanitizers such as WhiteList and ToString
  • custom validators registered by tag name

Alternatives

The same job

These do what govalidator does.

  1. validator Struct and field validation for Go, based on tags

Compare govalidator with the top 3