package customer import ( "time" "github.com/asaskevich/govalidator" ) // init registers custom validators func init() { // Register custom validators govalidator.CustomTypeTagMap.Set("unix_timestamp", govalidator.CustomTypeValidator(func(i interface{}, context interface{}) bool { switch v := i.(type) { case int64: // Check if timestamp is reasonable (not too old, not in the future) now := time.Now().Unix() minTimestamp := now - (100 * 365 * 24 * 60 * 60) // 100 years ago maxTimestamp := now + (10 * 365 * 24 * 60 * 60) // 10 years in future return v >= minTimestamp && v <= maxTimestamp case *int64: if v == nil { return true // nil is valid for optional fields } now := time.Now().Unix() minTimestamp := now - (100 * 365 * 24 * 60 * 60) // 100 years ago maxTimestamp := now + (10 * 365 * 24 * 60 * 60) // 10 years in future return *v >= minTimestamp && *v <= maxTimestamp default: return false } })) }