github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/external-types/models/embedded_time.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  	timeext "time"
    11  
    12  	"github.com/go-openapi/runtime"
    13  	"github.com/go-openapi/strfmt"
    14  )
    15  
    16  // EmbeddedTime
    17  // This type demonstrates how we can embed an external type and wraps the validation.
    18  //
    19  // This is especially useful if you want to reuse some types from the standard library,
    20  // such as `time.Time` or `json.RawMessage`.
    21  //
    22  // swagger:model EmbeddedTime
    23  type EmbeddedTime struct {
    24  	timeext.Time
    25  }
    26  
    27  func (m EmbeddedTime) Validate(formats strfmt.Registry) error {
    28  	var f interface{} = m.Time
    29  	if v, ok := f.(runtime.Validatable); ok {
    30  		return v.Validate(formats)
    31  	}
    32  	return nil
    33  }
    34  
    35  func (m EmbeddedTime) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    36  	var f interface{} = m.Time
    37  	if v, ok := f.(runtime.ContextValidatable); ok {
    38  		return v.ContextValidate(ctx, formats)
    39  	}
    40  	return nil
    41  }