github.com/djarvur/go-swagger@v0.18.0/examples/oauth2/models/error.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package models
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	strfmt "github.com/go-openapi/strfmt"
    10  
    11  	"github.com/go-openapi/errors"
    12  	"github.com/go-openapi/swag"
    13  	"github.com/go-openapi/validate"
    14  )
    15  
    16  // Error error
    17  // swagger:model error
    18  type Error struct {
    19  
    20  	// code
    21  	Code int64 `json:"code,omitempty"`
    22  
    23  	// fields
    24  	Fields string `json:"fields,omitempty"`
    25  
    26  	// message
    27  	// Required: true
    28  	Message *string `json:"message"`
    29  }
    30  
    31  // Validate validates this error
    32  func (m *Error) Validate(formats strfmt.Registry) error {
    33  	var res []error
    34  
    35  	if err := m.validateMessage(formats); err != nil {
    36  		res = append(res, err)
    37  	}
    38  
    39  	if len(res) > 0 {
    40  		return errors.CompositeValidationError(res...)
    41  	}
    42  	return nil
    43  }
    44  
    45  func (m *Error) validateMessage(formats strfmt.Registry) error {
    46  
    47  	if err := validate.Required("message", "body", m.Message); err != nil {
    48  		return err
    49  	}
    50  
    51  	return nil
    52  }
    53  
    54  // MarshalBinary interface implementation
    55  func (m *Error) MarshalBinary() ([]byte, error) {
    56  	if m == nil {
    57  		return nil, nil
    58  	}
    59  	return swag.WriteJSON(m)
    60  }
    61  
    62  // UnmarshalBinary interface implementation
    63  func (m *Error) UnmarshalBinary(b []byte) error {
    64  	var res Error
    65  	if err := swag.ReadJSON(b, &res); err != nil {
    66  		return err
    67  	}
    68  	*m = res
    69  	return nil
    70  }