github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/models/user_creation_req.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  // UserCreationReq user creation req
    18  //
    19  // swagger:model UserCreationReq
    20  type UserCreationReq struct {
    21  
    22  	// comment
    23  	Comment string `json:"comment,omitempty"`
    24  
    25  	// email
    26  	// Max Length: 255
    27  	Email string `json:"email,omitempty"`
    28  
    29  	// password
    30  	Password string `json:"password,omitempty"`
    31  
    32  	// realname
    33  	Realname string `json:"realname,omitempty"`
    34  
    35  	// username
    36  	// Max Length: 255
    37  	Username string `json:"username,omitempty"`
    38  }
    39  
    40  // Validate validates this user creation req
    41  func (m *UserCreationReq) Validate(formats strfmt.Registry) error {
    42  	var res []error
    43  
    44  	if err := m.validateEmail(formats); err != nil {
    45  		res = append(res, err)
    46  	}
    47  
    48  	if err := m.validateUsername(formats); err != nil {
    49  		res = append(res, err)
    50  	}
    51  
    52  	if len(res) > 0 {
    53  		return errors.CompositeValidationError(res...)
    54  	}
    55  	return nil
    56  }
    57  
    58  func (m *UserCreationReq) validateEmail(formats strfmt.Registry) error {
    59  	if swag.IsZero(m.Email) { // not required
    60  		return nil
    61  	}
    62  
    63  	if err := validate.MaxLength("email", "body", m.Email, 255); err != nil {
    64  		return err
    65  	}
    66  
    67  	return nil
    68  }
    69  
    70  func (m *UserCreationReq) validateUsername(formats strfmt.Registry) error {
    71  	if swag.IsZero(m.Username) { // not required
    72  		return nil
    73  	}
    74  
    75  	if err := validate.MaxLength("username", "body", m.Username, 255); err != nil {
    76  		return err
    77  	}
    78  
    79  	return nil
    80  }
    81  
    82  // ContextValidate validates this user creation req based on context it is used
    83  func (m *UserCreationReq) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    84  	return nil
    85  }
    86  
    87  // MarshalBinary interface implementation
    88  func (m *UserCreationReq) MarshalBinary() ([]byte, error) {
    89  	if m == nil {
    90  		return nil, nil
    91  	}
    92  	return swag.WriteJSON(m)
    93  }
    94  
    95  // UnmarshalBinary interface implementation
    96  func (m *UserCreationReq) UnmarshalBinary(b []byte) error {
    97  	var res UserCreationReq
    98  	if err := swag.ReadJSON(b, &res); err != nil {
    99  		return err
   100  	}
   101  	*m = res
   102  	return nil
   103  }