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