go-ozzo / ozzo-validation

An idiomatic Go (golang) validation package. Supports configurable and extensible validation rules (validators) using normal language constructs instead of error-prone struct tags.
MIT License
3.73k stars 224 forks source link

is.Float with decimal places #173

Open rngallen opened 2 years ago

rngallen commented 2 years ago

Can I use is.Float with specification of decimal places? I will always want my float to have two decimal places

type Foo struct {
    Bar float32 `json:"bar"`
}

func (f Foo) Validate() error {
    return validation.ValidateStruct(&f,
        validation.Field(&f.Bar, is.Float)) //<=== specify decimal places
}