checker

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 1 Imported by: 0

README

checker — generic validators

import "github.com/downsized-devs/sdk-go/checker"

Stability: Stable — see STABILITY.md

Tiny library of validation helpers. Uses generics; no external deps.

Features

  • ArrayInt64Contains, ArrayContains — membership tests.
  • ArrayDeduplicate — remove duplicates while preserving order.
  • IsEmail, IsPhoneNumber — regex-based format checks.

Installation

go get github.com/downsized-devs/sdk-go/checker

Quick Start

import "github.com/downsized-devs/sdk-go/checker"

ok := checker.ArrayContains([]string{"a", "b"}, "a") // true
clean := checker.ArrayDeduplicate([]int{1, 1, 2})    // [1, 2]
checker.IsEmail("alice@example.com")                 // true

API Reference

Symbol Signature
ArrayContains [T comparable](arr []T, target T) bool
ArrayInt64Contains (arr []int64, target int64) bool
ArrayDeduplicate [T AllowedDataType](arr []T) []T
IsEmail (s string) bool
IsPhoneNumber (s string) bool
AllowedDataType constraint interface (comparable types).

Dependencies

stdlib only.

Testing

go test ./checker/...

Contributing

See CONTRIBUTING.md.

Documentation

Overview

Package checker provides small validation predicates (phone, email) and generic slice helpers (Contains, Deduplicate) used throughout the SDK.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayContains

func ArrayContains[T AllowedDataType](slice []T, x T) bool

Check wether the slice in int64, string, or float data type contains the input x

func ArrayDeduplicate

func ArrayDeduplicate[T AllowedDataType](values []T) []T

Remove duplicate values in int64, string, or float data type slice

func ArrayInt64Contains

func ArrayInt64Contains(slice []int64, x int64) bool

Check wether the slice contains the input x

func IsEmail

func IsEmail(email string) bool

func IsPhoneNumber

func IsPhoneNumber(phone string) bool

Types

type AllowedDataType

type AllowedDataType interface {
	int64 | string | float64
}

Jump to

Keyboard shortcuts

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