validation

package
v0.0.0-...-965f207 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 7 Imported by: 0

README

Validation

The validation package provides functionality for validating data using the Go go-playground/validator package.

  • It initializes the validator instance with required struct enabled.
  • Registers a custom validation rule, max-one-space-allowed, which ensures that a string field contains at most one optional space character.
  • Handles translations for validation error messages.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Validate = validator.New(validator.WithRequiredStructEnabled())
	Trans    ut.Translator
)
View Source
var MaxOneSpaceValidator = func(fl validator.FieldLevel) bool {
	for _, key := range fl.Field().MapKeys() {
		if strings.Count(key.String(), " ") > 1 {
			return false
		}
	}

	return true
}

MaxOneSpaceValidator validates that a string field contains at most one optional space character

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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