github.com/weaviate/weaviate@v1.24.6/entities/models/c11y_vector_based_question.go (about)

     1  //                           _       _
     2  // __      _____  __ ___   ___  __ _| |_ ___
     3  // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
     4  //  \ V  V /  __/ (_| |\ V /| | (_| | ||  __/
     5  //   \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
     6  //
     7  //  Copyright © 2016 - 2024 Weaviate B.V. All rights reserved.
     8  //
     9  //  CONTACT: hello@weaviate.io
    10  //
    11  
    12  // Code generated by go-swagger; DO NOT EDIT.
    13  
    14  package models
    15  
    16  // This file was generated by the swagger tool.
    17  // Editing this file might prove futile when you re-run the swagger generate command
    18  
    19  import (
    20  	"context"
    21  	"strconv"
    22  
    23  	"github.com/go-openapi/errors"
    24  	"github.com/go-openapi/strfmt"
    25  	"github.com/go-openapi/swag"
    26  	"github.com/go-openapi/validate"
    27  )
    28  
    29  // C11yVectorBasedQuestion Receive question based on array of classes, properties and values.
    30  //
    31  // swagger:model C11yVectorBasedQuestion
    32  type C11yVectorBasedQuestion []*C11yVectorBasedQuestionItems0
    33  
    34  // Validate validates this c11y vector based question
    35  func (m C11yVectorBasedQuestion) Validate(formats strfmt.Registry) error {
    36  	var res []error
    37  
    38  	for i := 0; i < len(m); i++ {
    39  		if swag.IsZero(m[i]) { // not required
    40  			continue
    41  		}
    42  
    43  		if m[i] != nil {
    44  			if err := m[i].Validate(formats); err != nil {
    45  				if ve, ok := err.(*errors.Validation); ok {
    46  					return ve.ValidateName(strconv.Itoa(i))
    47  				} else if ce, ok := err.(*errors.CompositeError); ok {
    48  					return ce.ValidateName(strconv.Itoa(i))
    49  				}
    50  				return err
    51  			}
    52  		}
    53  
    54  	}
    55  
    56  	if len(res) > 0 {
    57  		return errors.CompositeValidationError(res...)
    58  	}
    59  	return nil
    60  }
    61  
    62  // ContextValidate validate this c11y vector based question based on the context it is used
    63  func (m C11yVectorBasedQuestion) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    64  	var res []error
    65  
    66  	for i := 0; i < len(m); i++ {
    67  
    68  		if m[i] != nil {
    69  			if err := m[i].ContextValidate(ctx, formats); err != nil {
    70  				if ve, ok := err.(*errors.Validation); ok {
    71  					return ve.ValidateName(strconv.Itoa(i))
    72  				} else if ce, ok := err.(*errors.CompositeError); ok {
    73  					return ce.ValidateName(strconv.Itoa(i))
    74  				}
    75  				return err
    76  			}
    77  		}
    78  
    79  	}
    80  
    81  	if len(res) > 0 {
    82  		return errors.CompositeValidationError(res...)
    83  	}
    84  	return nil
    85  }
    86  
    87  // C11yVectorBasedQuestionItems0 c11y vector based question items0
    88  //
    89  // swagger:model C11yVectorBasedQuestionItems0
    90  type C11yVectorBasedQuestionItems0 struct {
    91  
    92  	// Vectorized properties.
    93  	// Max Items: 300
    94  	// Min Items: 300
    95  	ClassProps []*C11yVectorBasedQuestionItems0ClassPropsItems0 `json:"classProps"`
    96  
    97  	// Vectorized classname.
    98  	// Max Items: 300
    99  	// Min Items: 300
   100  	ClassVectors []float32 `json:"classVectors"`
   101  }
   102  
   103  // Validate validates this c11y vector based question items0
   104  func (m *C11yVectorBasedQuestionItems0) Validate(formats strfmt.Registry) error {
   105  	var res []error
   106  
   107  	if err := m.validateClassProps(formats); err != nil {
   108  		res = append(res, err)
   109  	}
   110  
   111  	if err := m.validateClassVectors(formats); err != nil {
   112  		res = append(res, err)
   113  	}
   114  
   115  	if len(res) > 0 {
   116  		return errors.CompositeValidationError(res...)
   117  	}
   118  	return nil
   119  }
   120  
   121  func (m *C11yVectorBasedQuestionItems0) validateClassProps(formats strfmt.Registry) error {
   122  	if swag.IsZero(m.ClassProps) { // not required
   123  		return nil
   124  	}
   125  
   126  	iClassPropsSize := int64(len(m.ClassProps))
   127  
   128  	if err := validate.MinItems("classProps", "body", iClassPropsSize, 300); err != nil {
   129  		return err
   130  	}
   131  
   132  	if err := validate.MaxItems("classProps", "body", iClassPropsSize, 300); err != nil {
   133  		return err
   134  	}
   135  
   136  	for i := 0; i < len(m.ClassProps); i++ {
   137  		if swag.IsZero(m.ClassProps[i]) { // not required
   138  			continue
   139  		}
   140  
   141  		if m.ClassProps[i] != nil {
   142  			if err := m.ClassProps[i].Validate(formats); err != nil {
   143  				if ve, ok := err.(*errors.Validation); ok {
   144  					return ve.ValidateName("classProps" + "." + strconv.Itoa(i))
   145  				} else if ce, ok := err.(*errors.CompositeError); ok {
   146  					return ce.ValidateName("classProps" + "." + strconv.Itoa(i))
   147  				}
   148  				return err
   149  			}
   150  		}
   151  
   152  	}
   153  
   154  	return nil
   155  }
   156  
   157  func (m *C11yVectorBasedQuestionItems0) validateClassVectors(formats strfmt.Registry) error {
   158  	if swag.IsZero(m.ClassVectors) { // not required
   159  		return nil
   160  	}
   161  
   162  	iClassVectorsSize := int64(len(m.ClassVectors))
   163  
   164  	if err := validate.MinItems("classVectors", "body", iClassVectorsSize, 300); err != nil {
   165  		return err
   166  	}
   167  
   168  	if err := validate.MaxItems("classVectors", "body", iClassVectorsSize, 300); err != nil {
   169  		return err
   170  	}
   171  
   172  	return nil
   173  }
   174  
   175  // ContextValidate validate this c11y vector based question items0 based on the context it is used
   176  func (m *C11yVectorBasedQuestionItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   177  	var res []error
   178  
   179  	if err := m.contextValidateClassProps(ctx, formats); err != nil {
   180  		res = append(res, err)
   181  	}
   182  
   183  	if len(res) > 0 {
   184  		return errors.CompositeValidationError(res...)
   185  	}
   186  	return nil
   187  }
   188  
   189  func (m *C11yVectorBasedQuestionItems0) contextValidateClassProps(ctx context.Context, formats strfmt.Registry) error {
   190  
   191  	for i := 0; i < len(m.ClassProps); i++ {
   192  
   193  		if m.ClassProps[i] != nil {
   194  			if err := m.ClassProps[i].ContextValidate(ctx, formats); err != nil {
   195  				if ve, ok := err.(*errors.Validation); ok {
   196  					return ve.ValidateName("classProps" + "." + strconv.Itoa(i))
   197  				} else if ce, ok := err.(*errors.CompositeError); ok {
   198  					return ce.ValidateName("classProps" + "." + strconv.Itoa(i))
   199  				}
   200  				return err
   201  			}
   202  		}
   203  
   204  	}
   205  
   206  	return nil
   207  }
   208  
   209  // MarshalBinary interface implementation
   210  func (m *C11yVectorBasedQuestionItems0) MarshalBinary() ([]byte, error) {
   211  	if m == nil {
   212  		return nil, nil
   213  	}
   214  	return swag.WriteJSON(m)
   215  }
   216  
   217  // UnmarshalBinary interface implementation
   218  func (m *C11yVectorBasedQuestionItems0) UnmarshalBinary(b []byte) error {
   219  	var res C11yVectorBasedQuestionItems0
   220  	if err := swag.ReadJSON(b, &res); err != nil {
   221  		return err
   222  	}
   223  	*m = res
   224  	return nil
   225  }
   226  
   227  // C11yVectorBasedQuestionItems0ClassPropsItems0 c11y vector based question items0 class props items0
   228  //
   229  // swagger:model C11yVectorBasedQuestionItems0ClassPropsItems0
   230  type C11yVectorBasedQuestionItems0ClassPropsItems0 struct {
   231  
   232  	// props vectors
   233  	PropsVectors []float32 `json:"propsVectors"`
   234  
   235  	// String with valuename.
   236  	Value string `json:"value,omitempty"`
   237  }
   238  
   239  // Validate validates this c11y vector based question items0 class props items0
   240  func (m *C11yVectorBasedQuestionItems0ClassPropsItems0) Validate(formats strfmt.Registry) error {
   241  	return nil
   242  }
   243  
   244  // ContextValidate validates this c11y vector based question items0 class props items0 based on context it is used
   245  func (m *C11yVectorBasedQuestionItems0ClassPropsItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   246  	return nil
   247  }
   248  
   249  // MarshalBinary interface implementation
   250  func (m *C11yVectorBasedQuestionItems0ClassPropsItems0) MarshalBinary() ([]byte, error) {
   251  	if m == nil {
   252  		return nil, nil
   253  	}
   254  	return swag.WriteJSON(m)
   255  }
   256  
   257  // UnmarshalBinary interface implementation
   258  func (m *C11yVectorBasedQuestionItems0ClassPropsItems0) UnmarshalBinary(b []byte) error {
   259  	var res C11yVectorBasedQuestionItems0ClassPropsItems0
   260  	if err := swag.ReadJSON(b, &res); err != nil {
   261  		return err
   262  	}
   263  	*m = res
   264  	return nil
   265  }