// 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"
)

// HeaderFilter HeaderFilter represents a regex value filter applied to one particular HTTP header (allow / block).
//
// swagger:model HeaderFilter
type HeaderFilter struct {

	// Time at which the header filter was created (ISO 8601 Datetime).
	// Example: 2021-07-30T09:20:25+00:00
	// Read Only: true
	CreatedAt string `json:"created_at,omitempty"`

	// The ID of the admin account that created this header filter.
	// Example: 01FBW2758ZB6PBR200YPDDJK4C
	// Read Only: true
	CreatedBy string `json:"created_by,omitempty"`

	// The HTTP header to match against.
	// Example: User-Agent
	Header string `json:"header,omitempty"`

	// The ID of the header filter.
	// Example: 01FBW21XJA09XYX51KV5JVBW0F
	// Read Only: true
	ID string `json:"id,omitempty"`

	// The header value matching regular expression.
	// Example: .*Firefox.*
	Regex string `json:"regex,omitempty"`
}

// Validate validates this header filter
func (m *HeaderFilter) Validate(formats strfmt.Registry) error {
	return nil
}

// ContextValidate validate this header filter based on the context it is used
func (m *HeaderFilter) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

	if err := m.contextValidateCreatedAt(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateCreatedBy(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateID(ctx, formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *HeaderFilter) contextValidateCreatedAt(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "created_at", "body", string(m.CreatedAt)); err != nil {
		return err
	}

	return nil
}

func (m *HeaderFilter) contextValidateCreatedBy(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "created_by", "body", string(m.CreatedBy)); err != nil {
		return err
	}

	return nil
}

func (m *HeaderFilter) contextValidateID(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "id", "body", string(m.ID)); err != nil {
		return err
	}

	return nil
}

// MarshalBinary interface implementation
func (m *HeaderFilter) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *HeaderFilter) UnmarshalBinary(b []byte) error {
	var res HeaderFilter
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}
