github.com/aeternity/aepp-sdk-go@v1.0.3-0.20190606142815-1c0ffdc21fd9/generated/models/name_pointer.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  // NamePointer name pointer
    17  // swagger:model NamePointer
    18  type NamePointer struct {
    19  
    20  	// id
    21  	// Required: true
    22  	ID EncodedPubkey `json:"id"`
    23  
    24  	// key
    25  	// Required: true
    26  	Key *string `json:"key"`
    27  }
    28  
    29  // Validate validates this name pointer
    30  func (m *NamePointer) Validate(formats strfmt.Registry) error {
    31  	var res []error
    32  
    33  	if err := m.validateID(formats); err != nil {
    34  		res = append(res, err)
    35  	}
    36  
    37  	if err := m.validateKey(formats); err != nil {
    38  		res = append(res, err)
    39  	}
    40  
    41  	if len(res) > 0 {
    42  		return errors.CompositeValidationError(res...)
    43  	}
    44  	return nil
    45  }
    46  
    47  func (m *NamePointer) validateID(formats strfmt.Registry) error {
    48  
    49  	if err := m.ID.Validate(formats); err != nil {
    50  		if ve, ok := err.(*errors.Validation); ok {
    51  			return ve.ValidateName("id")
    52  		}
    53  		return err
    54  	}
    55  
    56  	return nil
    57  }
    58  
    59  func (m *NamePointer) validateKey(formats strfmt.Registry) error {
    60  
    61  	if err := validate.Required("key", "body", m.Key); err != nil {
    62  		return err
    63  	}
    64  
    65  	return nil
    66  }
    67  
    68  // MarshalBinary interface implementation
    69  func (m *NamePointer) MarshalBinary() ([]byte, error) {
    70  	if m == nil {
    71  		return nil, nil
    72  	}
    73  	return swag.WriteJSON(m)
    74  }
    75  
    76  // UnmarshalBinary interface implementation
    77  func (m *NamePointer) UnmarshalBinary(b []byte) error {
    78  	var res NamePointer
    79  	if err := swag.ReadJSON(b, &res); err != nil {
    80  		return err
    81  	}
    82  	*m = res
    83  	return nil
    84  }