github.com/djarvur/go-swagger@v0.18.0/examples/oauth2/models/customer.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  // Customer customer
    17  // swagger:model customer
    18  type Customer struct {
    19  
    20  	// agent associated with this customer
    21  	AgentID int32 `json:"agentId,omitempty"`
    22  
    23  	// internal identifier of a customer
    24  	// Required: true
    25  	// Read Only: true
    26  	CustomerID int64 `json:"customerId"`
    27  
    28  	// fips code
    29  	// Required: true
    30  	// Min Length: 1
    31  	FipsCode *string `json:"fipsCode"`
    32  
    33  	// name
    34  	// Required: true
    35  	// Min Length: 1
    36  	Name *string `json:"name"`
    37  
    38  	// Lookup identifier to find a customer in the system
    39  	// Required: true
    40  	// Min Length: 11
    41  	Ssn *string `json:"ssn"`
    42  
    43  	// surname
    44  	// Required: true
    45  	// Min Length: 1
    46  	Surname *string `json:"surname"`
    47  }
    48  
    49  // Validate validates this customer
    50  func (m *Customer) Validate(formats strfmt.Registry) error {
    51  	var res []error
    52  
    53  	if err := m.validateCustomerID(formats); err != nil {
    54  		res = append(res, err)
    55  	}
    56  
    57  	if err := m.validateFipsCode(formats); err != nil {
    58  		res = append(res, err)
    59  	}
    60  
    61  	if err := m.validateName(formats); err != nil {
    62  		res = append(res, err)
    63  	}
    64  
    65  	if err := m.validateSsn(formats); err != nil {
    66  		res = append(res, err)
    67  	}
    68  
    69  	if err := m.validateSurname(formats); err != nil {
    70  		res = append(res, err)
    71  	}
    72  
    73  	if len(res) > 0 {
    74  		return errors.CompositeValidationError(res...)
    75  	}
    76  	return nil
    77  }
    78  
    79  func (m *Customer) validateCustomerID(formats strfmt.Registry) error {
    80  
    81  	if err := validate.Required("customerId", "body", int64(m.CustomerID)); err != nil {
    82  		return err
    83  	}
    84  
    85  	return nil
    86  }
    87  
    88  func (m *Customer) validateFipsCode(formats strfmt.Registry) error {
    89  
    90  	if err := validate.Required("fipsCode", "body", m.FipsCode); err != nil {
    91  		return err
    92  	}
    93  
    94  	if err := validate.MinLength("fipsCode", "body", string(*m.FipsCode), 1); err != nil {
    95  		return err
    96  	}
    97  
    98  	return nil
    99  }
   100  
   101  func (m *Customer) validateName(formats strfmt.Registry) error {
   102  
   103  	if err := validate.Required("name", "body", m.Name); err != nil {
   104  		return err
   105  	}
   106  
   107  	if err := validate.MinLength("name", "body", string(*m.Name), 1); err != nil {
   108  		return err
   109  	}
   110  
   111  	return nil
   112  }
   113  
   114  func (m *Customer) validateSsn(formats strfmt.Registry) error {
   115  
   116  	if err := validate.Required("ssn", "body", m.Ssn); err != nil {
   117  		return err
   118  	}
   119  
   120  	if err := validate.MinLength("ssn", "body", string(*m.Ssn), 11); err != nil {
   121  		return err
   122  	}
   123  
   124  	return nil
   125  }
   126  
   127  func (m *Customer) validateSurname(formats strfmt.Registry) error {
   128  
   129  	if err := validate.Required("surname", "body", m.Surname); err != nil {
   130  		return err
   131  	}
   132  
   133  	if err := validate.MinLength("surname", "body", string(*m.Surname), 1); err != nil {
   134  		return err
   135  	}
   136  
   137  	return nil
   138  }
   139  
   140  // MarshalBinary interface implementation
   141  func (m *Customer) MarshalBinary() ([]byte, error) {
   142  	if m == nil {
   143  		return nil, nil
   144  	}
   145  	return swag.WriteJSON(m)
   146  }
   147  
   148  // UnmarshalBinary interface implementation
   149  func (m *Customer) UnmarshalBinary(b []byte) error {
   150  	var res Customer
   151  	if err := swag.ReadJSON(b, &res); err != nil {
   152  		return err
   153  	}
   154  	*m = res
   155  	return nil
   156  }