myvalidator

command module
v0.0.0-...-99299c1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 11 Imported by: 0

README

MyValidator (terrible name, fix it!)

Validator is an amazing project. But in applications with high frequency use, the way that validator works (i.e. reflection) can cause performance penalty.

MyValidator born to solve that gap. Instead of use reflection, MyValidator uses the code generating approach.

This project aims to be compatible with validator tag syntax.

At this time it is an unstable project and should not be used in production environments.

How to build MyValidator

The following requirements are needed to build the project:

  • Git
  • Go >= 1.22
  • Make

The steps to build are:

# Clone the project repository
git clone git@github.com:alexgarzao/myvalidator.git

# Run the tests (optional)
make test

# Build the binary
make build

After that the executable will be in bin/myvalidator.

Steps to run the tests

Steps to run test01

Test01 aims to be a case where all the files are in the same package (in this case, the main package).

# Runs myvalidator to generate structs validator and common definitions.
./bin/myvalidator ./tests/test01

After that two files will be generated:

  • validators.go: contains common definitions
  • user_validator.go: contains UserValidate function that is responsible to check if User object has a valid content

Steps to run test02

Test02 aims to be an example where the structs to be validated are in another package (structsinpkg in this test).

# Runs myvalidator to generate structs validator and common definitions.
./bin/myvalidator ./tests/test02

After that two files will be generated:

  • validators.go: contains common definitions
  • user_validator.go: contains UserValidate function that is responsible to check if User object has a valid content

License

MyValidator uses MIT License.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
tests

Jump to

Keyboard shortcuts

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