// 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"
	"encoding/json"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
	"github.com/go-openapi/validate"
)

// Transformation transformation
//
// swagger:model Transformation
type Transformation struct {

	// expression
	Expression string `json:"expression,omitempty"`

	// field
	Field string `json:"field,omitempty"`

	// map value
	MapValue string `json:"mapValue,omitempty"`

	// type
	// Enum: [regex logfmt]
	Type string `json:"type,omitempty"`
}

// Validate validates this transformation
func (m *Transformation) Validate(formats strfmt.Registry) error {
	var res []error

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

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

var transformationTypeTypePropEnum []interface{}

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["regex","logfmt"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		transformationTypeTypePropEnum = append(transformationTypeTypePropEnum, v)
	}
}

const (

	// TransformationTypeRegex captures enum value "regex"
	TransformationTypeRegex string = "regex"

	// TransformationTypeLogfmt captures enum value "logfmt"
	TransformationTypeLogfmt string = "logfmt"
)

// prop value enum
func (m *Transformation) validateTypeEnum(path, location string, value string) error {
	if err := validate.EnumCase(path, location, value, transformationTypeTypePropEnum, true); err != nil {
		return err
	}
	return nil
}

func (m *Transformation) validateType(formats strfmt.Registry) error {
	if swag.IsZero(m.Type) { // not required
		return nil
	}

	// value enum
	if err := m.validateTypeEnum("type", "body", m.Type); err != nil {
		return err
	}

	return nil
}

// ContextValidate validates this transformation based on context it is used
func (m *Transformation) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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