valid

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: MIT Imports: 19 Imported by: 0

README

About Valid

Valid is a robust and extensible validation library for handling data and input validation in Go applications. It simplifies the process of validating user inputs, structs, etc., making it easier to ensure data integrity and validity in Golang projects.

Contributing

Thank you for considering contributing to the Valid package. seyramprikah@gmail.com.

License

The Valid package is open-sourced licensed under the MIT license.

Documentation

Overview

Package valid is a robust and extensible validation library.

This package handle data and input validation in Go applications.

Index

Constants

View Source
const (

	// LocaleFR constant variable for fr locale
	LocaleFR = "fr"
	// DriverPostgres postgres driver for database connection
	DriverPostgres = "postgres"
	// DriverMysql mysql driver for database connection
	DriverMysql = "mysql"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Locale string
	DB     *Database
}

Config is configuration struct for Validate.

type Database

type Database struct {
	Host     string
	Port     int
	Name     string
	Username string
	Password string
	Driver   string
	SSLMode  string
}

Database configuration

type Validator

type Validator interface {
	// ValidateStruct performs validation on struct.
	// It takes struct pointer as parameter.
	ValidateStruct(elem any) map[string]any
	// RequestStruct takes struct pointer as parameter.
	RequestStruct(elem any) Validator
	// ValidateRequest performs validation on in coming request.
	// It is a middleware that takes http.Handler as parameter and return  http.Handler.
	ValidateRequest(next http.Handler) http.Handler
	// ValidateMap performs validation on map.
	// It takes map pointer as parameter.
	ValidateMap(elem map[string]any, rule map[string]string, message ...map[string]string) map[string]any
}

func New

func New(config ...*Config) Validator

New takes optional @Config object. Valid use this configuration to connect to your database to check for exist field in validation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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