is

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package is provides standalone validation checks returning bool. Use package validate when you need an error describing why a check failed.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func BIC added in v0.20.0

func BIC(value string, options ...func(*validate.BICOptions)) bool

BIC validates whether the value is a valid Business Identifier Code (BIC / SWIFT). See github.com/muonsoft/validation/validate.BIC for validation rules and options.

See https://en.wikipedia.org/wiki/ISO_9362.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
	"github.com/muonsoft/validation/validate"
)

func main() {
	fmt.Println(is.BIC("DEUTDEFF"))
	fmt.Println(is.BIC("DEUTDEF"))
	fmt.Println(is.BIC("deutdeff", validate.BICCaseInsensitive()))
}
Output:
true
false
true

func CIDR added in v0.20.0

func CIDR(value string, options ...func(*validate.CIDROptions)) bool

CIDR checks that a value is valid CIDR notation (IP/prefix). See github.com/muonsoft/validation/validate.CIDR for options and error semantics.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
	"github.com/muonsoft/validation/validate"
)

func main() {
	fmt.Println(is.CIDR("192.168.0.0/24"))
	fmt.Println(is.CIDR("10.0.0.0/33"))
	fmt.Println(is.CIDR("2001:db8::/32", validate.CIDRVersion("4")))
}
Output:
true
false
false

func CSSColor added in v0.20.0

func CSSColor(value string, formats ...validate.CSSColorFormat) bool

CSSColor reports whether value is a CSS color in any selected format. No formats selects all supported formats. See validate.CSSColor for supported formats and empty-value behavior.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.CSSColor("rgba(0,0,0,.5)"))
}
Output:
true

func CardScheme added in v0.20.0

func CardScheme(value string, schemes ...validate.CardSchemeName) bool

CardScheme reports whether value matches any of the explicitly selected schemes. See validate.CardScheme for supported schemes and empty-value behavior.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
	"github.com/muonsoft/validation/validate"
)

func main() {
	fmt.Println(is.CardScheme("4111111111111111", validate.CardSchemeVisa))
}
Output:
true

func Country added in v0.20.0

func Country(value string) bool

Country reports whether value is a valid two-letter country or territory code. Empty strings pass. Case is ignored and whitespace is not trimmed. Uses x/text country data, including CLDR additions and historical codes; acceptance does not imply service availability. See validate.Country for the full contract and data-version limitations.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.Country("de"))
	fmt.Println(is.Country("EU"))
}
Output:
true
false

func Currency added in v0.20.0

func Currency(value string) bool

Currency validates whether the value is a recognized ISO 4217 alphabetic currency code. See github.com/muonsoft/validation/validate.Currency for rules and possible errors.

See https://www.iso.org/iso-4217-currency-codes.html.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.Currency("EUR"))
	fmt.Println(is.Currency("ZZZ"))
	fmt.Println(is.Currency("EU"))
}
Output:
true
false
false

func DivisibleBy added in v0.17.0

func DivisibleBy(divisible, divisor float64) bool

DivisibleBy checks that a value is divisible by another value (divisor). It checks that the remainder is zero or almost zero with an error of 1e-12.

func EAN8 added in v0.8.0

func EAN8(value string) bool

EAN8 checks that string contains valid EAN-8 code.

See https://en.wikipedia.org/wiki/EAN-8.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.EAN8("42345671"))
	fmt.Println(is.EAN8("47195127"))
	fmt.Println(is.EAN8("00000000")) // zeros only are prohibited
	fmt.Println(is.EAN8("42345670")) // invalid checksum
	fmt.Println(is.EAN8("A4234671")) // contains non-digit
}
Output:
true
true
false
false
false

func EAN13 added in v0.8.0

func EAN13(value string) bool

EAN13 checks that string contains valid EAN-13 code.

See https://en.wikipedia.org/wiki/International_Article_Number.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.EAN13("4719512002889"))
	fmt.Println(is.EAN13("9782868890061"))
	fmt.Println(is.EAN13("0000000000000")) // zeros only are prohibited
	fmt.Println(is.EAN13("4006381333932")) // invalid checksum
	fmt.Println(is.EAN13("A782868890061")) // contains non-digit
}
Output:
true
true
false
false
false

func Email

func Email(value string) bool

Email is used for simplified validation of an email address. It allows all values with an "@" symbol in, and a "." in the second host part of the email address.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.Email("user@example.com"))         // valid
	fmt.Println(is.Email("{}~!@example.com"))         // valid
	fmt.Println(is.Email("пользователь@example.com")) // valid
	fmt.Println(is.Email("user example.com"))         // invalid
}
Output:
true
true
true
false

func HTML5Email

func HTML5Email(value string) bool

HTML5Email is used for validation of an email address based on pattern for HTML5 (see https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address).

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.HTML5Email("user@example.com"))         // valid
	fmt.Println(is.HTML5Email("{}~!@example.com"))         // valid
	fmt.Println(is.HTML5Email("пользователь@example.com")) // invalid
	fmt.Println(is.HTML5Email("user example.com"))         // invalid
}
Output:
true
true
false
false

func Hostname

func Hostname(value string) bool

Hostname checks that a value is a valid hostname. It checks that each label within a valid hostname may be no more than 63 octets long. Also, it checks that the total length of the hostname must not exceed 255 characters.

See StrictHostname for additional checks.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.Hostname("example.com"))       // valid
	fmt.Println(is.Hostname("example.localhost")) // valid
	fmt.Println(is.Hostname("com"))               // valid
	fmt.Println(is.Hostname("example-.com"))      // invalid
}
Output:
true
true
true
false

func IBAN added in v0.20.0

func IBAN(value string) bool

IBAN validates whether the value is a valid International Bank Account Number (IBAN). See github.com/muonsoft/validation/validate.IBAN for validation rules.

See https://en.wikipedia.org/wiki/International_Bank_Account_Number.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.IBAN("DE89370400440532013000"))
	fmt.Println(is.IBAN("DE89370400440532013001"))
	fmt.Println(is.IBAN("US64SVBX1101057138"))
}
Output:
true
false
false

func IP

func IP(value string, restrictions ...func(ip net.IP) error) bool

IP checks that a value is a valid IP address (IPv4 or IPv6). You can use a list of restrictions to additionally check for a restricted range of IPs.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
	"github.com/muonsoft/validation/validate"
)

func main() {
	fmt.Println(is.IP("123.123.123.123"))                         // valid IPv4
	fmt.Println(is.IP("2001:0db8:85a3:0000:0000:8a2e:0370:7334")) // valid IPv6
	fmt.Println(is.IP("123.123.123.345"))                         // invalid
	fmt.Println(is.IP("192.168.1.0"))                             // non-restricted private IP
	fmt.Println(is.IP("192.168.1.0", validate.DenyPrivateIP()))   // restricted private IP
}
Output:
true
true
false
true
false

func IPv4

func IPv4(value string, restrictions ...func(ip net.IP) error) bool

IPv4 checks that a value is a valid IPv4 address. You can use a list of restrictions to additionally check for a restricted range of IPs.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
	"github.com/muonsoft/validation/validate"
)

func main() {
	fmt.Println(is.IPv4("123.123.123.123"))                         // valid IPv4
	fmt.Println(is.IPv4("2001:0db8:85a3:0000:0000:8a2e:0370:7334")) // invalid (IPv6)
	fmt.Println(is.IPv4("123.123.123.345"))                         // invalid
	fmt.Println(is.IPv4("192.168.1.0"))                             // non-restricted private IP
	fmt.Println(is.IPv4("192.168.1.0", validate.DenyPrivateIP()))   // restricted private IP
}
Output:
true
false
false
true
false

func IPv6

func IPv6(value string, restrictions ...func(ip net.IP) error) bool

IPv6 checks that a value is a valid IPv6 address. You can use a list of restrictions to additionally check for a restricted range of IPs.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
	"github.com/muonsoft/validation/validate"
)

func main() {
	fmt.Println(is.IPv6("2001:0db8:85a3:0000:0000:8a2e:0370:7334"))                           // valid (IPv6)
	fmt.Println(is.IPv6("123.123.123.123"))                                                   // invalid IPv4
	fmt.Println(is.IPv6("z001:0db8:85a3:0000:0000:8a2e:0370:7334"))                           // invalid
	fmt.Println(is.IPv6("fdfe:dcba:9876:ffff:fdc6:c46b:bb8f:7d4c"))                           // non-restricted private IP
	fmt.Println(is.IPv6("fdfe:dcba:9876:ffff:fdc6:c46b:bb8f:7d4c", validate.DenyPrivateIP())) // restricted private IP
}
Output:
true
false
false
true
false

func ISBN added in v0.20.0

func ISBN(value string, options ...func(*validate.ISBNOptions)) bool

ISBN validates whether the value is a valid ISBN-10 or ISBN-13. See github.com/muonsoft/validation/validate.ISBN for options and possible errors.

See https://en.wikipedia.org/wiki/ISBN.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.ISBN("978-0451225245"))
	fmt.Println(is.ISBN("978272344228"))
	fmt.Println(is.ISBN("1234567890"))
}
Output:
true
false
false

func ISIN added in v0.20.0

func ISIN(value string) bool

ISIN validates whether the value is a valid International Securities Identification Number (ISIN). See github.com/muonsoft/validation/validate.ISIN for validation rules and possible errors.

See https://en.wikipedia.org/wiki/International_Securities_Identification_Number.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.ISIN("US0378331005"))
	fmt.Println(is.ISIN("US037833100"))
	fmt.Println(is.ISIN("123456789101"))
	fmt.Println(is.ISIN("XS2012239364"))
}
Output:
true
false
false
false

func ISSN added in v0.20.0

func ISSN(value string) bool

ISSN validates whether the value is a valid International Standard Serial Number (ISSN). See github.com/muonsoft/validation/validate.ISSN for validation rules and possible errors.

See https://www.issn.org/understanding-the-issn/what-is-an-issn/.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.ISSN("0317-8471"))
	fmt.Println(is.ISSN("03178471"))
	fmt.Println(is.ISSN("2434-561X"))
	fmt.Println(is.ISSN("0317-8470"))
	fmt.Println(is.ISSN("123-45678"))
}
Output:
true
true
true
false
false

func InList added in v0.9.0

func InList[T comparable](value T, list []T) bool

InList returns true if one of the elements of the list is equal to the value.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.InList("foo", nil))
	fmt.Println(is.InList("foo", []string{"bar", "baz"}))
	fmt.Println(is.InList("foo", []string{"bar", "baz", "foo"}))
	fmt.Println(is.InList(2, []int{1, 2, 3}))
}
Output:
false
false
true
true

func Integer added in v0.5.1

func Integer(s string) bool

Integer checks that string is an integer.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.Integer("123"))
	fmt.Println(is.Integer("123.123"))
	fmt.Println(is.Integer("-123"))
	fmt.Println(is.Integer("123foo"))
}
Output:
true
false
true
false

func JSON

func JSON(value string) bool

JSON checks that value is a valid JSON string.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.JSON(`{"valid": true}`)) // valid
	fmt.Println(is.JSON(`"invalid": true`)) // invalid
}
Output:
true
false

func LUHN added in v0.20.0

func LUHN(value string) bool

LUHN validates whether the value passes the Luhn (mod 10) checksum. See github.com/muonsoft/validation/validate.LUHN for validation rules and possible errors.

See https://en.wikipedia.org/wiki/Luhn_algorithm.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.LUHN("79927398713"))
	fmt.Println(is.LUHN("79927398710"))
	fmt.Println(is.LUHN("12345a"))
}
Output:
true
false
false

func Language added in v0.20.0

func Language(value string) bool

Language reports whether value is a valid standalone two- or three-letter language code. Empty strings pass. Case is ignored and whitespace is not trimmed. Composite tags require Locale. Special and private-use codes recognized by x/text are accepted; acceptance does not imply translation availability. See validate.Language for the full contract and data-version limitations.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.Language("eng"))
	fmt.Println(is.Language("en-US"))
}
Output:
true
false

func Locale added in v0.20.0

func Locale(value string) bool

Locale reports whether value is a valid locale identifier. Empty strings pass. Case is ignored and whitespace is not trimmed. Accepts composite tags, underscore separators, special and private-use tags, and extensions supported by x/text; acceptance does not imply application support. See validate.Locale for the full contract and data-version limitations.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.Locale("zh_Hant_TW"))
	fmt.Println(is.Locale("en--US"))
}
Output:
true
false

func MACAddress added in v0.20.0

func MACAddress(value string, options ...func(*validate.MacAddressOptions)) bool

MACAddress checks that a value is a valid 48-bit MAC address with optional Symfony-compatible type filtering. See github.com/muonsoft/validation/validate.MacAddress for options.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
	"github.com/muonsoft/validation/validate"
)

func main() {
	fmt.Println(is.MACAddress("00:1a:2b:3c:4d:5e"))
	fmt.Println(is.MACAddress("bad"))
	fmt.Println(is.MACAddress("ff:ff:ff:ff:ff:ff", validate.WithMacAddressType(validate.MacAddressTypeBroadcast)))
}
Output:
true
false
true

func Number added in v0.5.1

func Number(s string) bool

Number checks that string is a number (a float or an integer).

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.Number("123"))
	fmt.Println(is.Number("123.123"))
	fmt.Println(is.Number("123e123"))
	fmt.Println(is.Number("-123"))
	fmt.Println(is.Number("123foo"))
}
Output:
true
true
true
true
false

func StrictHostname

func StrictHostname(value string) bool

StrictHostname checks that a value is a valid hostname. Beside checks from Hostname function it checks that hostname is fully qualified and include its top-level domain name (TLD). For instance, example.com is valid but example is not.

Additionally it checks for reserved top-level domains according to RFC 2606 and that's why hostnames containing them are not considered valid: .example, .invalid, .localhost, and .test.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.StrictHostname("example.com"))       // valid
	fmt.Println(is.StrictHostname("example.localhost")) // reserved
	fmt.Println(is.StrictHostname("com"))               // invalid
	fmt.Println(is.StrictHostname("example-.com"))      // invalid
}
Output:
true
false
false
false

func Timezone added in v0.20.0

func Timezone(value string, options ...func(*validate.TimezoneOptions)) bool

Timezone validates whether the value is a known IANA timezone identifier. See github.com/muonsoft/validation/validate.Timezone for rules and options.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
	"github.com/muonsoft/validation/validate"
)

func main() {
	fmt.Println(is.Timezone("Europe/Berlin"))
	fmt.Println(is.Timezone("EST"))
	fmt.Println(is.Timezone("America/Chicago", validate.WithTimezoneZone(validate.TimezoneZoneAmerica)))
}
Output:
true
false
true

func ULID added in v0.17.0

func ULID(value string) bool

ULID validates whether the value is a valid ULID (Universally Unique Lexicographically Sortable Identifier). See https://github.com/ulid/spec for ULID specifications.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.ULID("01ARZ3NDEKTSV4RRFFQ69G5FAV"))
	fmt.Println(is.ULID("01ARZ3NDEKTSV4RRFFQ69G5FA"))   // too short
	fmt.Println(is.ULID("01ARZ3NDEKTSV4RRFFQ69G5FAVA")) // too long
	fmt.Println(is.ULID("01ARZ3NDEKTSV4RRFFQ69G5FAO"))  // invalid characters
	fmt.Println(is.ULID("81ARZ3NDEKTSV4RRFFQ69G5FAV"))  // too large
}
Output:
true
false
false
false
false

func UPCA added in v0.8.0

func UPCA(value string) bool

UPCA checks that string contains valid UPC-A code.

See https://en.wikipedia.org/wiki/Universal_Product_Code.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.UPCA("614141000036"))
	fmt.Println(is.UPCA("123456789999"))
	fmt.Println(is.UPCA("000000000000")) // zeros only are prohibited
	fmt.Println(is.UPCA("614141000037")) // invalid checksum
	fmt.Println(is.UPCA("A14141000036")) // contains non-digit
}
Output:
true
true
false
false
false

func UPCE added in v0.8.0

func UPCE(value string) bool

UPCE checks that string contains valid UPC-E code.

See https://en.wikipedia.org/wiki/Universal_Product_Code#UPC-E.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.UPCE("123456"))   // 6-digit is always valid
	fmt.Println(is.UPCE("1234505"))  // 7-digit with last check digit
	fmt.Println(is.UPCE("01234505")) // 8-digit with first zero and last check digit
	fmt.Println(is.UPCE("00000000")) // zeros only are prohibited
	fmt.Println(is.UPCE("11234505")) // non-zero number system is prohibited
	fmt.Println(is.UPCE("01234501")) // invalid checksum
	fmt.Println(is.UPCE("A2345673")) // contains non-digit
	fmt.Println(is.UPCE("12345"))    // invalid length
}
Output:
true
true
true
false
false
false
false
false

func URL

func URL(value string, restrictions ...func(u *url.URL) error) bool

URL is used to validate that value is a valid URL string. You can use a list of restrictions to additionally check for a restricted set of URLs. By default, if no restrictions are passed, the function checks for the http:// and https:// schemas.

Use the callable option to configure the list of expected schemas. If an empty string is passed as a schema, then URL value may be treated as relative (without schema, e.g. "//example.com").

Use the github.com/muonsoft/validation/validate.RestrictURLHosts or github.com/muonsoft/validation/validate.RestrictURLHostByPattern option to configure the list of allowed hosts.

Example
package main

import (
	"fmt"
	"regexp"

	"github.com/muonsoft/validation/is"
	"github.com/muonsoft/validation/validate"
)

func main() {
	fmt.Println(is.URL("https://example.com"))                                                    // valid absolute URL
	fmt.Println(is.URL("ftp://example.com", validate.RestrictURLSchemas("http", "https", "ftp"))) // valid URL with custom schema
	fmt.Println(is.URL("example.com"))                                                            // invalid URL
	fmt.Println(is.URL("//example.com", validate.RestrictURLSchemas("")))                         // valid relative URL
	fmt.Println(is.URL("http://example.com", validate.RestrictURLHosts("sample.com")))            // not matching host
	fmt.Println(                                                                                  // matching by regexp
		is.URL(
			"http://sub.example.com",
			validate.RestrictURLHostByPattern(regexp.MustCompile(`^.*\.example\.com$`)),
		),
	)
}
Output:
true
true
false
true
false
true

func UTF8 added in v0.20.0

func UTF8(value string) bool

UTF8 reports whether value is valid UTF-8, including the empty string. Use it to reject malformed or truncated bytes from imports or integrations. It checks encoding only, not text meaning or safety, and does not detect, convert, or normalize encodings. See validate.UTF8 for limitations.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.UTF8("Привет 🙂"))
	fmt.Println(is.UTF8("\xff"))
	fmt.Println(is.UTF8(""))
}
Output:
true
false
true

func UUID added in v0.17.0

func UUID(value string, options ...func(o *validate.UUIDOptions)) bool

UUID validates whether a string value is a valid UUID (also known as GUID).

By default, it uses strict mode and checks the UUID as specified in RFC 4122. To parse additional formats, use the github.com/muonsoft/validation/validate.AllowNonCanonicalUUIDFormats option.

In addition, it checks if the UUID version matches one of the registered versions: 1, 2, 3, 4, 5, 6 or 7. Use github.com/muonsoft/validation/validate.AllowUUIDVersions to validate for a specific set of versions.

Nil UUID ("00000000-0000-0000-0000-000000000000") values are considered as valid. Use github.com/muonsoft/validation/validate.DenyNilUUID to disallow nil value.

See http://tools.ietf.org/html/rfc4122.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
	"github.com/muonsoft/validation/validate"
)

func main() {
	fmt.Println(is.UUID("83eab6fd-230b-44fe-b52f-463387bd8788"))                                      // v4
	fmt.Println(is.UUID("83eab6fd-230b-44fe-b52f-463387bd8788", validate.AllowUUIDVersions(4)))       // v4
	fmt.Println(is.UUID("00000000-0000-0000-0000-000000000000"))                                      // nil UUID
	fmt.Println(is.UUID("00000000-0000-0000-0000-000000000000", validate.DenyNilUUID()))              // deny nil UUID
	fmt.Println(is.UUID("x3eab6fd-230b-44fe-b52f-463387bd8788"))                                      // invalid
	fmt.Println(is.UUID("216fff40-98d9-f1e3-a5e2-0800200c9a66"))                                      // invalid version
	fmt.Println(is.UUID("216fff4098d911e3a5e20800200c9a66"))                                          // non-canonical
	fmt.Println(is.UUID("216fff4098d911e3a5e20800200c9a66", validate.AllowNonCanonicalUUIDFormats())) // non-canonical
}
Output:
true
true
true
false
false
false
false
true

func Unique added in v0.9.0

func Unique[T comparable](values []T) bool

Unique checks that the slice of comparable values are unique.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.Unique([]string{}))
	fmt.Println(is.Unique([]string{"one", "two", "three"}))
	fmt.Println(is.Unique([]string{"one", "two", "one"}))
	fmt.Println(is.Unique([]int{1, 2, 1}))
}
Output:
true
true
false
false

func Week added in v0.20.0

func Week(value string, options ...func(*validate.WeekOptions)) bool

Week reports whether value is a valid ISO week within optional inclusive bounds. See validate.Week for format, year range, options, and empty-value behavior.

Example
package main

import (
	"fmt"

	"github.com/muonsoft/validation/is"
)

func main() {
	fmt.Println(is.Week("2020-W53"))
	fmt.Println(is.Week("2021-W53"))
}
Output:
true
false

Types

This section is empty.

Jump to

Keyboard shortcuts

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