github.com/aeternity/aepp-sdk-go/v4@v4.0.1/swagguard/node/models/dry_run_input.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  	"strconv"
    10  
    11  	strfmt "github.com/go-openapi/strfmt"
    12  
    13  	"github.com/go-openapi/errors"
    14  	"github.com/go-openapi/swag"
    15  	"github.com/go-openapi/validate"
    16  )
    17  
    18  // DryRunInput dry run input
    19  // swagger:model DryRunInput
    20  type DryRunInput struct {
    21  
    22  	// Accounts
    23  	Accounts []*DryRunAccount `json:"accounts"`
    24  
    25  	// top
    26  	Top string `json:"top,omitempty"`
    27  
    28  	// Txs
    29  	// Required: true
    30  	Txs []string `json:"txs"`
    31  }
    32  
    33  // Validate validates this dry run input
    34  func (m *DryRunInput) Validate(formats strfmt.Registry) error {
    35  	var res []error
    36  
    37  	if err := m.validateAccounts(formats); err != nil {
    38  		res = append(res, err)
    39  	}
    40  
    41  	if err := m.validateTxs(formats); err != nil {
    42  		res = append(res, err)
    43  	}
    44  
    45  	if len(res) > 0 {
    46  		return errors.CompositeValidationError(res...)
    47  	}
    48  	return nil
    49  }
    50  
    51  func (m *DryRunInput) validateAccounts(formats strfmt.Registry) error {
    52  
    53  	if swag.IsZero(m.Accounts) { // not required
    54  		return nil
    55  	}
    56  
    57  	for i := 0; i < len(m.Accounts); i++ {
    58  		if swag.IsZero(m.Accounts[i]) { // not required
    59  			continue
    60  		}
    61  
    62  		if m.Accounts[i] != nil {
    63  			if err := m.Accounts[i].Validate(formats); err != nil {
    64  				if ve, ok := err.(*errors.Validation); ok {
    65  					return ve.ValidateName("accounts" + "." + strconv.Itoa(i))
    66  				}
    67  				return err
    68  			}
    69  		}
    70  
    71  	}
    72  
    73  	return nil
    74  }
    75  
    76  func (m *DryRunInput) validateTxs(formats strfmt.Registry) error {
    77  
    78  	if err := validate.Required("txs", "body", m.Txs); err != nil {
    79  		return err
    80  	}
    81  
    82  	return nil
    83  }
    84  
    85  // MarshalBinary interface implementation
    86  func (m *DryRunInput) MarshalBinary() ([]byte, error) {
    87  	if m == nil {
    88  		return nil, nil
    89  	}
    90  	return swag.WriteJSON(m)
    91  }
    92  
    93  // UnmarshalBinary interface implementation
    94  func (m *DryRunInput) UnmarshalBinary(b []byte) error {
    95  	var res DryRunInput
    96  	if err := swag.ReadJSON(b, &res); err != nil {
    97  		return err
    98  	}
    99  	*m = res
   100  	return nil
   101  }