decimalvalidators

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: MIT Imports: 3 Imported by: 0

README

Adds decimal validators to github.com/go-playground/validator for github.com/shopspring/decimal

Usage:

package main

import (
	"fmt"

	"github.com/go-playground/validator/v10"
	dv "github.com/sblackstone/shopspring-decimal-validators"
	"github.com/shopspring/decimal"
)

func main() {

	v := validator.New()
	dv.RegisterDecimalValidators(v)

	rec := struct {
		Val decimal.Decimal `validate:"dgt=10"`
	}{}

	rec.Val = decimal.NewFromInt(9)
	err := v.Struct(rec)
	fmt.Printf("%s", err.Error())

}

Validators:

Tag Description
dgt Greater Than
dgte Greater Than Or Equal
dlt Less Than
dlte Less Than Or Equal
deq Equal
dneq Not Equal

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterDecimalValidators

func RegisterDecimalValidators(v *validator.Validate)

Types

This section is empty.

Jump to

Keyboard shortcuts

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