datacheckr

package module
v0.0.0-...-3816c45 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: MIT Imports: 4 Imported by: 0

README

Datacheckr

Welcome to the Datacheckr Go package! This package is designed to simplify the process of validating various types of data within your Go applications.

Projected Features

  1. primitive checker: int, boolean, string etc.

  2. min max value checker ✅

  3. min max length checker ✅

  4. email checker ✅

  5. special string checker

  6. struct and map validation

  7. time checker: before, after, equalto, before or equalto, after or equalto checker

  8. url scheme validation ✅

Incomplete

LICENSE

MIT

Documentation

Index

Constants

View Source
const (
	EmailRegexStr string = `^[a-zA-Z0-9._%]+@[a-zA-Z0-9]+\.[a-zA-Z]{2,}$`
	URLSubdomain  string = `((www\.)|([a-zA-Z0-9]+([-_\.]?[a-zA-Z0-9])*[a-zA-Z0-9]\.[a-zA-Z0-9]+))`
)
View Source
const (
	NotAValidIntegerErrMsg string = "data validation failed: integer required"
)

Variables

Functions

func EmailValidation

func EmailValidation(value any) bool

func UrlSchemeValidation

func UrlSchemeValidation(value any) bool

Types

type Number

type Number interface {
	constraints.Integer | constraints.Float
}

type ValidationRule

type ValidationRule = func(any) bool

func MaxStrLenValidation

func MaxStrLenValidation(maxLen int) ValidationRule

func MaxValValidation

func MaxValValidation[Num Number](maxVal Num) ValidationRule

func MinStrLenValidation

func MinStrLenValidation(minLen int) ValidationRule

func MinValValidation

func MinValValidation[Num Number](minVal Num) ValidationRule

type Validator

type Validator struct {
	ValidationRules []ValidationRule
}

we can apply multiple validations to the data

func NewValidatorInstance

func NewValidatorInstance() *Validator

func (*Validator) AddValidationRules

func (validator *Validator) AddValidationRules(validations ...ValidationRule)

to get validation rules are applied to the data

func (*Validator) Validate

func (validator *Validator) Validate(data any) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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