Golidators is a golang package, it includes basic data validation functions and regexes.
$ go get github.com/eredotpkfr/golidators
Following validators available on this package:
- Domain
- MD5, SHA1, SHA224, SHA256, SHA512
- IPv4, IPv4CIDR, IPv6, IPv6CIDR
- MAC
- Port
- URL
- UUID
Just import and use it. Also see documentation at pkg.go.dev
package main
import (
"github.com/eredotpkfr/golidators"
"fmt"
)
func main() {
fmt.Println(golidators.Domain("www.example.com"))
// true
fmt.Println(golidators.Ipv4("::1"))
// false
fmt.Println(golidators.Ipv6("::1"))
// true
fmt.Println(golidators.Url("https://www.example.com"))
// true
fmt.Println(golidators.Ipv4Cidr("127.0.0.1/12"))
// true
fmt.Println(golidators.Md5("foo/bar"))
// false
}
Blog - erdoganyoksul.com
Mail - [email protected]