github.com/aeternity/aepp-sdk-go/v4@v4.0.1/swagguard/node/models/generation.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  // Generation generation
    17  // swagger:model Generation
    18  type Generation struct {
    19  
    20  	// key block
    21  	// Required: true
    22  	KeyBlock *KeyBlock `json:"key_block"`
    23  
    24  	// micro blocks
    25  	// Required: true
    26  	MicroBlocks []string `json:"micro_blocks"`
    27  }
    28  
    29  // Validate validates this generation
    30  func (m *Generation) Validate(formats strfmt.Registry) error {
    31  	var res []error
    32  
    33  	if err := m.validateKeyBlock(formats); err != nil {
    34  		res = append(res, err)
    35  	}
    36  
    37  	if err := m.validateMicroBlocks(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 *Generation) validateKeyBlock(formats strfmt.Registry) error {
    48  
    49  	if err := validate.Required("key_block", "body", m.KeyBlock); err != nil {
    50  		return err
    51  	}
    52  
    53  	if m.KeyBlock != nil {
    54  		if err := m.KeyBlock.Validate(formats); err != nil {
    55  			if ve, ok := err.(*errors.Validation); ok {
    56  				return ve.ValidateName("key_block")
    57  			}
    58  			return err
    59  		}
    60  	}
    61  
    62  	return nil
    63  }
    64  
    65  func (m *Generation) validateMicroBlocks(formats strfmt.Registry) error {
    66  
    67  	if err := validate.Required("micro_blocks", "body", m.MicroBlocks); err != nil {
    68  		return err
    69  	}
    70  
    71  	return nil
    72  }
    73  
    74  // MarshalBinary interface implementation
    75  func (m *Generation) MarshalBinary() ([]byte, error) {
    76  	if m == nil {
    77  		return nil, nil
    78  	}
    79  	return swag.WriteJSON(m)
    80  }
    81  
    82  // UnmarshalBinary interface implementation
    83  func (m *Generation) UnmarshalBinary(b []byte) error {
    84  	var res Generation
    85  	if err := swag.ReadJSON(b, &res); err != nil {
    86  		return err
    87  	}
    88  	*m = res
    89  	return nil
    90  }