Skip to content

goloop/is

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Report Card License License Stay with Ukraine

is

is is a comprehensive set of format-validation functions for the data types you meet in web, financial and general Go applications — emails, phone numbers, bank cards, IBANs, coordinates, IP/host/URL, hashes, UUIDs, character classes and number properties.

Every function answers a single yes/no question about the format of its input. The package does not clean or normalise data: it validates exactly what you pass in. Need to strip spaces or separators first? Clean the input (for example with the g package), then validate.

Features

  • IdentityEmail, Nickname, VariableName, VariableNameFor (language-aware, reserved words included).
  • FinancialBankCard (Luhn + optional brand), IBAN/IBANCountry.
  • GeographicLatitude, Longitude, Coordinates (string or float64).
  • NetworkIPv4/IPv6/IP, MAC, URL, Hostname, Domain, Phone, E164.
  • Character classesAlpha, Alnum, Digit, Numeric, Decimal, Float, Lower/Upper/Title, Space.
  • NumbersEven/Odd, Whole, Natural, Positive/Negative/Zero.
  • Encoding & formatBase64/Base64URL, Hex/Bin, HexColor/ RGBColor, MD5/SHA1/SHA256/SHA512, UUID, JWT.
  • TelecomIMEI, IMSI.

Installation

go get -u github.com/goloop/is/v2
import "github.com/goloop/is/v2"

Requires Go 1.24 or newer. The package has no third-party dependencies.

Quick start

package main

import (
    "fmt"

    "github.com/goloop/is/v2"
)

func main() {
    fmt.Println(is.Email("user@example.com"))         // true
    fmt.Println(is.Phone("+1 (234) 567-8900"))        // true
    fmt.Println(is.E164("+12345678900"))              // true
    fmt.Println(is.Coordinates(51.5074, -0.1278))     // true

    // BankCard: any brand, or require a specific one.
    fmt.Println(is.BankCard("4111111111111111"))          // true
    fmt.Println(is.BankCard("4111111111111111", is.Visa)) // true
    fmt.Println(is.IBAN("DE89370400440532013000"))        // true

    // Formats and hashes.
    fmt.Println(is.HexColor("#FF5733"))                             // true
    fmt.Println(is.UUID("550e8400-e29b-41d4-a716-446655440000"))    // true
}

Because is never cleans input, strip noise first when needed:

raw := "GB82 WEST 1234 5698 7654 32"   // contains spaces
iban := g.Weed(raw, g.Whitespaces)     // remove them
ok := is.IBAN(iban)                    // validate

Documentation

Contributing

Contributions are welcome. Please run go test ./..., go vet ./... and gofmt -l . before submitting a pull request.

License

is is released under the MIT License. See LICENSE.

About

Package includes validation functions of various data such as e-mail, bank card number, bank account IBAN, phone number and others.

Topics

Resources

License

Code of conduct

Contributing

Stars

4 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages