github.com/djarvur/go-swagger@v0.18.0/examples/authentication/models/social_id.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  // SocialID social id
    17  // swagger:model social_id
    18  type SocialID struct {
    19  
    20  	// ssn
    21  	// Required: true
    22  	// Min Length: 11
    23  	Ssn *string `json:"ssn"`
    24  }
    25  
    26  // Validate validates this social id
    27  func (m *SocialID) Validate(formats strfmt.Registry) error {
    28  	var res []error
    29  
    30  	if err := m.validateSsn(formats); err != nil {
    31  		res = append(res, err)
    32  	}
    33  
    34  	if len(res) > 0 {
    35  		return errors.CompositeValidationError(res...)
    36  	}
    37  	return nil
    38  }
    39  
    40  func (m *SocialID) validateSsn(formats strfmt.Registry) error {
    41  
    42  	if err := validate.Required("ssn", "body", m.Ssn); err != nil {
    43  		return err
    44  	}
    45  
    46  	if err := validate.MinLength("ssn", "body", string(*m.Ssn), 11); err != nil {
    47  		return err
    48  	}
    49  
    50  	return nil
    51  }
    52  
    53  // MarshalBinary interface implementation
    54  func (m *SocialID) MarshalBinary() ([]byte, error) {
    55  	if m == nil {
    56  		return nil, nil
    57  	}
    58  	return swag.WriteJSON(m)
    59  }
    60  
    61  // UnmarshalBinary interface implementation
    62  func (m *SocialID) UnmarshalBinary(b []byte) error {
    63  	var res SocialID
    64  	if err := swag.ReadJSON(b, &res); err != nil {
    65  		return err
    66  	}
    67  	*m = res
    68  	return nil
    69  }