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