Closed rafa-acioly closed 4 years ago
I've tried to pass a string on the validation.Date() method and i'm getting this error:
string
validation.Date()
end_at: must be either a string or byte slice; start_at: must be either a string or byte slice.
The struct:
type Price struct { StartAt time.Time `bson:"start_at" json:"start_at"` EndAt time.Time `bson:"end_at" json:"end_at"` }
The validation:
func (p Price) isValid() error { return validation.ValidateStruct(&p, validation.Field(&p.StartAt, validation.Required, validation.Date("")), validation.Field(&p.EndAt, validation.Required, validation.Date("").Min(p.StartAt)), ) }
The payload:
{ "end_at": "2019-10-01T00:00:00Z", "start_at": "2019-11-01T00:00:00Z" }
the doc says:
An empty value is considered valid. Use the Required rule to make sure a value is not empty.
Can i set a min value using another field?
The Date rule is used to validate a date/time string. You can use Min and Max rules to validate the range of a time.Time value.
Date
Min
Max
time.Time
I've tried to pass a
string
on thevalidation.Date()
method and i'm getting this error:The struct:
The validation:
The payload:
the doc says:
Can i set a min value using another field?