golidators

package module
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2024 License: MIT Imports: 4 Imported by: 1

README

Workflow Go Report Card Go Reference Go Version Release License Stars

golidators

Golidators is a golang package, it includes basic data validation functions and regexes

Install

~$ go get github.com/eredotpkfr/golidators

Overview

Following validators available on this package:

  • Domain
  • MD5, SHA1, SHA224, SHA256, SHA512
  • IPv4, IPv4CIDR, IPv6, IPv6CIDR
  • MAC
  • Port
  • URL
  • UUID
  • CreditCard/Luhn

Usage

Just import and use it. Also see documentation at pkg.go.dev

package main

import (
    "github.com/eredotpkfr/golidators"
    "fmt"
)

func main() {
  // Validate domain address
  fmt.Println(golidators.Domain("www.example.com"))
  // Validate IPv4 address
  fmt.Println(golidators.Ipv4("::1"))
  // Validate IPv6 address
  fmt.Println(golidators.Ipv6("::1"))
  // Validate URL
  fmt.Println(golidators.Url("https://www.example.com"))
  // Validate IPv4CIDR
  fmt.Println(golidators.Ipv4Cidr("127.0.0.1/12"))
  // Validate most common hashes
  fmt.Println(golidators.Md5("foo/bar"))
  // Validate with Luhn algorithm
  fmt.Println(golidators.Luhn(5300025108592596))
  // Calculate check digit with Luhn algorithm
  fmt.Println(golidators.LuhnCheckDigit(5146713835433))
  // Validate credit card number with Luhn
  fmt.Println(golidators.CreditCard(5184214431476070))
}

Contact

Blog - erdoganyoksul.com
Mail - erdoganyoksul3@gmail.com

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreditCard added in v0.1.6

func CreditCard(number int) bool

CreditCard validate credit card number with Luhn

func Domain

func Domain(domain string) bool

Domain function for validating domains

func Ipv4

func Ipv4(ipv4Addr string) bool

Ipv4 function for validating IPv4

func Ipv4Cidr

func Ipv4Cidr(ipv4AddrCidr string) bool

Ipv4Cidr function for validating IPv4CIDR

func Ipv6

func Ipv6(ipv6Addr string) bool

Ipv6 function for validating IPv6

func Ipv6Cidr

func Ipv6Cidr(ipv6AddrCidr string) bool

Ipv6Cidr function for validating IPv6CIDR

func Luhn added in v0.1.6

func Luhn(number int) bool

Luhn checks if the given integer is valid according to the Luhn algorithm

func LuhnCheckDigit added in v0.1.6

func LuhnCheckDigit(number int) int

LuhnCheckDigit calculates the check digit for a given number using the Luhn algorithm

func Mac added in v0.1.3

func Mac(macAddr string) bool

Mac function for validating MAC Addresses

func Md5

func Md5(md5 string) bool

Md5 function for validating MD5

func Port

func Port(port int) bool

Port function for validating ports

func Sha1

func Sha1(sha1 string) bool

Sha1 function for validating SHA1

func Sha224

func Sha224(sha224 string) bool

Sha224 function for validating SHA224

func Sha256

func Sha256(sha256 string) bool

Sha256 function for validating SHA256

func Sha512

func Sha512(sha512 string) bool

Sha512 function for validating SHA512

func Url

func Url(url string) bool

Url function for validating URL's

func Uuid added in v0.1.3

func Uuid(uuid string) bool

Uuid function for validating UUID

Types

This section is empty.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL