// Code generated by go-swagger; DO NOT EDIT.

package model

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

// CentralAuth0AuditLogReq central auth0 audit log req
//
// swagger:model centralAuth0AuditLogReq
type CentralAuth0AuditLogReq struct {

	// failure info
	// Required: true
	FailureInfo *string `json:"failure_info"`

	// is success
	// Required: true
	IsSuccess *bool `json:"is_success"`

	// operation
	// Required: true
	Operation *CentralAuth0AuditLogReqOperation `json:"operation"`

	// org id
	OrgID string `json:"org_id,omitempty"`
}

// Validate validates this central auth0 audit log req
func (m *CentralAuth0AuditLogReq) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *CentralAuth0AuditLogReq) validateFailureInfo(formats strfmt.Registry) error {

	if err := validate.Required("failure_info", "body", m.FailureInfo); err != nil {
		return err
	}

	return nil
}

func (m *CentralAuth0AuditLogReq) validateIsSuccess(formats strfmt.Registry) error {

	if err := validate.Required("is_success", "body", m.IsSuccess); err != nil {
		return err
	}

	return nil
}

func (m *CentralAuth0AuditLogReq) validateOperation(formats strfmt.Registry) error {

	if err := validate.Required("operation", "body", m.Operation); err != nil {
		return err
	}

	if err := validate.Required("operation", "body", m.Operation); err != nil {
		return err
	}

	if m.Operation != nil {
		if err := m.Operation.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("operation")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("operation")
			}
			return err
		}
	}

	return nil
}

// ContextValidate validate this central auth0 audit log req based on the context it is used
func (m *CentralAuth0AuditLogReq) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *CentralAuth0AuditLogReq) contextValidateOperation(ctx context.Context, formats strfmt.Registry) error {

	if m.Operation != nil {

		if err := m.Operation.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("operation")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("operation")
			}
			return err
		}
	}

	return nil
}

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

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