package
module
Version:
v1.0.3
Opens a new window with list of versions in this module.
Published: Oct 30, 2023
License: MIT
Opens a new window with license information.
Imports: 3
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
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
¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.