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

package models

import (
	"context"

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

// ExamplepbErrorObject examplepb error object
//
// swagger:model examplepbErrorObject
type ExamplepbErrorObject struct {

	// code
	//
	// Response code
	Code int64 `json:"code,omitempty"`

	// message
	//
	// Response message
	// Pattern: ^[a-zA-Z0-9]{1, 32}$
	Message string `json:"message,omitempty"`
}

// Validate validates this examplepb error object
func (m *ExamplepbErrorObject) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *ExamplepbErrorObject) validateMessage(formats strfmt.Registry) error {
	if swag.IsZero(m.Message) { // not required
		return nil
	}

	if err := validate.Pattern("message", "body", m.Message, `^[a-zA-Z0-9]{1, 32}$`); err != nil {
		return err
	}

	return nil
}

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

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

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