Popularity
1.8
Growing
Activity
7.0
Growing
24
0
0

Programming language: Go
Tags: Validation    
Latest version: v1.1.0

gody alternatives and similar packages

Based on the "Validation" category

Do you think we are missing an alternative of gody or a related project?

Add another 'Validation' Package

README

gody

:balloon: A lightweight struct validator for Go

Mentioned in Awesome Go GoDoc Go Report Card Build Status Coverage Status GitHub release (latest by date)

Installation

go get github.com/guiferpa/gody@v1.1.0

Usage

package main

import (
    "log"

    "github.com/guiferpa/gody"
    "github.com/guiferpa/gody/rule"
)

type Body struct {
    Text string `json:"text" validate:"not_empty"`
}

func main() {
    b := Body{}

    if validated, err := gody.Validate(b, nil); err != nil {
        if !validated {
            log.Println("body didn't validate:", err)
        }

        switch err.(type) {
        case *rule.ErrNotEmpty:
            log.Println(err)
        }
    }
}

Kinds of validation