// Code generated by go-swagger; DO NOT EDIT. package models // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command import ( "context" "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) // MediaMeta MediaMeta models media metadata. // // This can be metadata about an image, an audio file, video, etc. // // swagger:model MediaMeta type MediaMeta struct { // focus Focus *MediaFocus `json:"focus,omitempty"` // original Original *MediaDimensions `json:"original,omitempty"` // small Small *MediaDimensions `json:"small,omitempty"` } // Validate validates this media meta func (m *MediaMeta) Validate(formats strfmt.Registry) error { var res []error if err := m.validateFocus(formats); err != nil { res = append(res, err) } if err := m.validateOriginal(formats); err != nil { res = append(res, err) } if err := m.validateSmall(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } func (m *MediaMeta) validateFocus(formats strfmt.Registry) error { if swag.IsZero(m.Focus) { // not required return nil } if m.Focus != nil { if err := m.Focus.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("focus") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("focus") } return err } } return nil } func (m *MediaMeta) validateOriginal(formats strfmt.Registry) error { if swag.IsZero(m.Original) { // not required return nil } if m.Original != nil { if err := m.Original.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("original") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("original") } return err } } return nil } func (m *MediaMeta) validateSmall(formats strfmt.Registry) error { if swag.IsZero(m.Small) { // not required return nil } if m.Small != nil { if err := m.Small.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("small") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("small") } return err } } return nil } // ContextValidate validate this media meta based on the context it is used func (m *MediaMeta) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error if err := m.contextValidateFocus(ctx, formats); err != nil { res = append(res, err) } if err := m.contextValidateOriginal(ctx, formats); err != nil { res = append(res, err) } if err := m.contextValidateSmall(ctx, formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } func (m *MediaMeta) contextValidateFocus(ctx context.Context, formats strfmt.Registry) error { if m.Focus != nil { if swag.IsZero(m.Focus) { // not required return nil } if err := m.Focus.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("focus") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("focus") } return err } } return nil } func (m *MediaMeta) contextValidateOriginal(ctx context.Context, formats strfmt.Registry) error { if m.Original != nil { if swag.IsZero(m.Original) { // not required return nil } if err := m.Original.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("original") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("original") } return err } } return nil } func (m *MediaMeta) contextValidateSmall(ctx context.Context, formats strfmt.Registry) error { if m.Small != nil { if swag.IsZero(m.Small) { // not required return nil } if err := m.Small.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("small") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("small") } return err } } return nil } // MarshalBinary interface implementation func (m *MediaMeta) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } return swag.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *MediaMeta) UnmarshalBinary(b []byte) error { var res MediaMeta if err := swag.ReadJSON(b, &res); err != nil { return err } *m = res return nil }