func ShouldBeEquivalentTo(actual interface{}, expecteds ...interface{}) string { expected := expecteds[0] if actual == nil || expected == nil { return "" } if reflect.DeepEqual(expected, actual) { return "" } actualType := reflect.TypeOf(actual) expectedType := reflect.TypeOf(expected) if reflect.TypeOf(actual).ConvertibleTo(expectedType) { expectedValue := reflect.ValueOf(expected) if swag.IsZero(expectedValue) && swag.IsZero(reflect.ValueOf(actual)) { return "" } // Attempt comparison after type conversion if reflect.DeepEqual(actual, expectedValue.Convert(actualType).Interface()) { return "" } } // Last ditch effort if fmt.Sprintf("%#v", expected) == fmt.Sprintf("%#v", actual) { return "" } errFmt := "Expected: '%T(%#v)'\nActual: '%T(%#v)'\n(Should be equivalent)!" return fmt.Sprintf(errFmt, expected, expected, actual, actual) }
func assertEquivalent(t testing.TB, actual, expected interface{}) bool { if actual == nil || expected == nil || reflect.DeepEqual(actual, expected) { return true } actualType := reflect.TypeOf(actual) expectedType := reflect.TypeOf(expected) if reflect.TypeOf(actual).ConvertibleTo(expectedType) { expectedValue := reflect.ValueOf(expected) if swag.IsZero(expectedValue) && swag.IsZero(reflect.ValueOf(actual)) { return true } // Attempt comparison after type conversion if reflect.DeepEqual(actual, expectedValue.Convert(actualType).Interface()) { return true } } // Last ditch effort if fmt.Sprintf("%#v", expected) == fmt.Sprintf("%#v", actual) { return true } errFmt := "Expected: '%T(%#v)'\nActual: '%T(%#v)'\n(Should be equivalent)!" return assert.Fail(t, errFmt, expected, expected, actual, actual) }
func (m *TaskCard) validateTags(formats strfmt.Registry) error { if swag.IsZero(m.Tags) { // not required return nil } iTagsSize := int64(len(m.Tags)) if err := validate.MaxItems("tags", "body", iTagsSize, 5); err != nil { return err } if err := validate.UniqueItems("tags", "body", m.Tags); err != nil { return err } for i := 0; i < len(m.Tags); i++ { if err := validate.MinLength("tags"+"."+strconv.Itoa(i), "body", string(m.Tags[i]), 3); err != nil { return err } if err := validate.Pattern("tags"+"."+strconv.Itoa(i), "body", string(m.Tags[i]), `\w[\w- ]+`); err != nil { return err } } return nil }
func (m *Organization) validateTaxationStrategies(formats strfmt.Registry) error { if swag.IsZero(m.TaxationStrategies) { // not required return nil } return nil }
func (m *JGroupLimitRestrictions) validateProvider(formats strfmt.Registry) error { if swag.IsZero(m.Provider) { // not required return nil } return nil }
func (m *ShipmentDto) validateItems(formats strfmt.Registry) error { if swag.IsZero(m.Items) { // not required return nil } return nil }
func (m *ItemDto) validateReference(formats strfmt.Registry) error { if swag.IsZero(m.Reference) { // not required return nil } return nil }
func (m *TransitTimeResponse) validateTransitTimes(formats strfmt.Registry) error { if swag.IsZero(m.TransitTimes) { // not required return nil } return nil }
func (m *ProductRatePlan) validateFixedTermDefinitions(formats strfmt.Registry) error { if swag.IsZero(m.FixedTermDefinitions) { // not required return nil } return nil }
func (m *Pet) validateTags(formats strfmt.Registry) error { if swag.IsZero(m.Tags) { // not required return nil } return nil }
func (m *DeliveryPointDto) validateOpeningHour(formats strfmt.Registry) error { if swag.IsZero(m.OpeningHour) { // not required return nil } return nil }
func (m *Subscription) validatePricingComponentValues(formats strfmt.Registry) error { if swag.IsZero(m.PricingComponentValues) { // not required return nil } return nil }
func (m *ServicePointInformationDto) validateCoordinate(formats strfmt.Registry) error { if swag.IsZero(m.Coordinate) { // not required return nil } return nil }
func (m *Subscription) validatePaymentMethodSubscriptionLinks(formats strfmt.Registry) error { if swag.IsZero(m.PaymentMethodSubscriptionLinks) { // not required return nil } return nil }
func (m *Subscription) validateFixedTerms(formats strfmt.Registry) error { if swag.IsZero(m.FixedTerms) { // not required return nil } return nil }
func (m *UpdateProfileRequest) validateAddresses(formats strfmt.Registry) error { if swag.IsZero(m.Addresses) { // not required return nil } return nil }
func (m *DropOffTimeDatas) validateDropOffTimeData(formats strfmt.Registry) error { if swag.IsZero(m.DropOffTimeData) { // not required return nil } return nil }
func (m *ServicePointInformationDto) validateOpeningHour(formats strfmt.Registry) error { if swag.IsZero(m.OpeningHour) { // not required return nil } return nil }
func (m *JGroupLimitRestrictions) validateSupports(formats strfmt.Registry) error { if swag.IsZero(m.Supports) { // not required return nil } return nil }
func (m *JGroupLimit) validateAllowedInstances(formats strfmt.Registry) error { if swag.IsZero(m.AllowedInstances) { // not required return nil } return nil }
func (m *DeliveryPointDto) validateCoordinate(formats strfmt.Registry) error { if swag.IsZero(m.Coordinate) { // not required return nil } return nil }
func (m *ServicePointInformationResponse) validateServicePoints(formats strfmt.Registry) error { if swag.IsZero(m.ServicePoints) { // not required return nil } return nil }
func (m *Fault) validateParamValues(formats strfmt.Registry) error { if swag.IsZero(m.ParamValues) { // not required return nil } return nil }
func (m *Organization) validateAPIConfigurations(formats strfmt.Registry) error { if swag.IsZero(m.APIConfigurations) { // not required return nil } return nil }
func (m *ProductRatePlan) validateAggregatingComponents(formats strfmt.Registry) error { if swag.IsZero(m.AggregatingComponents) { // not required return nil } return nil }
func (m *Organization) validateDunningLines(formats strfmt.Registry) error { if swag.IsZero(m.DunningLines) { // not required return nil } return nil }
func (m *ProductRatePlan) validateTaxation(formats strfmt.Registry) error { if swag.IsZero(m.Taxation) { // not required return nil } return nil }
func (m *Organization) validateOrganizationGateways(formats strfmt.Registry) error { if swag.IsZero(m.OrganizationGateways) { // not required return nil } return nil }
func (m *ShipmentDto) validateShipmentReference(formats strfmt.Registry) error { if swag.IsZero(m.ShipmentReference) { // not required return nil } return nil }
func (m *ItemDto) validateItemRefID(formats strfmt.Registry) error { if swag.IsZero(m.ItemRefID) { // not required return nil } return nil }