// 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" "github.com/go-openapi/validate" ) // Filter Filter in NeoFS EACL to check particular properties of the request or the object. // Example: {"headerType":"OBJECT","key":"FileName","matchType":"STRING_NOT_EQUAL","value":"myfile"} // // swagger:model Filter type Filter struct { // header type // Required: true HeaderType *HeaderType `json:"headerType"` // key // Required: true Key *string `json:"key"` // match type // Required: true MatchType *MatchType `json:"matchType"` // value // Required: true Value *string `json:"value"` } // Validate validates this filter func (m *Filter) Validate(formats strfmt.Registry) error { var res []error if err := m.validateHeaderType(formats); err != nil { res = append(res, err) } if err := m.validateKey(formats); err != nil { res = append(res, err) } if err := m.validateMatchType(formats); err != nil { res = append(res, err) } if err := m.validateValue(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } func (m *Filter) validateHeaderType(formats strfmt.Registry) error { if err := validate.Required("headerType", "body", m.HeaderType); err != nil { return err } if err := validate.Required("headerType", "body", m.HeaderType); err != nil { return err } if m.HeaderType != nil { if err := m.HeaderType.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("headerType") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("headerType") } return err } } return nil } func (m *Filter) validateKey(formats strfmt.Registry) error { if err := validate.Required("key", "body", m.Key); err != nil { return err } return nil } func (m *Filter) validateMatchType(formats strfmt.Registry) error { if err := validate.Required("matchType", "body", m.MatchType); err != nil { return err } if err := validate.Required("matchType", "body", m.MatchType); err != nil { return err } if m.MatchType != nil { if err := m.MatchType.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("matchType") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("matchType") } return err } } return nil } func (m *Filter) validateValue(formats strfmt.Registry) error { if err := validate.Required("value", "body", m.Value); err != nil { return err } return nil } // ContextValidate validate this filter based on the context it is used func (m *Filter) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error if err := m.contextValidateHeaderType(ctx, formats); err != nil { res = append(res, err) } if err := m.contextValidateMatchType(ctx, formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } func (m *Filter) contextValidateHeaderType(ctx context.Context, formats strfmt.Registry) error { if m.HeaderType != nil { if err := m.HeaderType.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("headerType") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("headerType") } return err } } return nil } func (m *Filter) contextValidateMatchType(ctx context.Context, formats strfmt.Registry) error { if m.MatchType != nil { if err := m.MatchType.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("matchType") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("matchType") } return err } } return nil } // MarshalBinary interface implementation func (m *Filter) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } return swag.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Filter) UnmarshalBinary(b []byte) error { var res Filter if err := swag.ReadJSON(b, &res); err != nil { return err } *m = res return nil }