https://github.com/siberia-projects/siberia-validation
Siberia-validation is a library for a simple and convenient validation a passed value It's pretty easy to use and extend if you need a custom validation logic
https://github.com/siberia-projects/siberia-validation
customizable easy-to-use framework go siberia validation
Last synced: 3 months ago
JSON representation
Siberia-validation is a library for a simple and convenient validation a passed value It's pretty easy to use and extend if you need a custom validation logic
- Host: GitHub
- URL: https://github.com/siberia-projects/siberia-validation
- Owner: siberia-projects
- License: apache-2.0
- Created: 2024-01-21T13:59:55.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-13T12:32:49.000Z (about 2 years ago)
- Last Synced: 2024-06-21T18:54:12.821Z (almost 2 years ago)
- Topics: customizable, easy-to-use, framework, go, siberia, validation
- Language: Go
- Homepage:
- Size: 32.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Siberia Validation
=================
[](https://github.com/siberia-projects)
[](https://github.com/siberia-projects/siberia-validation)
## What is it?
Siberia-validation is a library for a simple and convenient validation a passed value
It's pretty easy to use and extend if you need a custom validation logic
## How to download?
```console
john@doe-pc:~$ go get github.com/siberia-projects/siberia-validation
```
## How to use?
To use it you have to do the following:
- Create all necessary **ConstraintValidator(s)**
- Create a **SimpleConstraintValidatorRegistry**
- Put them into the **SimpleConstraintValidatorRegistry**
- Create a **SimpleValidator** with passing the registry
- Execute a method **Validate()** with passing a value you want to validate
and all needed **Constraint(s)**
For your convenience the **NewSimpleConstraintValidatorRegistryWithDefaultValidators** exists
If a value is invalid you will have a **ConstraintViolationError** which holds every violation error inside itself
## Examples
```go
package main
import (
"github.com/siberia-projects/siberia-validation/pkg/validation"
)
func main() {
registry := validation.NewSimpleConstraintValidatorRegistryWithDefaultValidators()
validator := validation.NewSimpleValidator(registry)
err := validator.Validate("valid_value", []validation.Constraint{
&validation.NotNil{},
&validation.NotBlank{},
})
if err != nil {
println(err.Error())
return
}
println("Everything is valid!")
}
```