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

Validating empty string or zero integer #100

Closed mandeepkhatry closed 4 years ago

mandeepkhatry commented 4 years ago

For eg. validation.Validate(data, validation.Min(10)) (data here is an integer in my case) doesn't validate zero integer. Is there a way in which I can validate zero integer? So that it results "must be no less than 10".

maratori commented 4 years ago

@mandeepkhatry As doc says you should use Required. https://github.com/go-ozzo/ozzo-validation/blob/master/minmax.go#L42

// An empty value is considered valid. Please use the Required rule to make sure a value is not empty.

qiangxue commented 4 years ago

@maratori Thank you for helping answer the question!