github.com/crowdsecurity/crowdsec@v1.6.1/pkg/modelscapi/add_signals_request_item_decisions.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package modelscapi
     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  	"strconv"
    11  
    12  	"github.com/go-openapi/errors"
    13  	"github.com/go-openapi/strfmt"
    14  	"github.com/go-openapi/swag"
    15  )
    16  
    17  // AddSignalsRequestItemDecisions Decisions list
    18  //
    19  // swagger:model AddSignalsRequestItemDecisions
    20  type AddSignalsRequestItemDecisions []*AddSignalsRequestItemDecisionsItem
    21  
    22  // Validate validates this add signals request item decisions
    23  func (m AddSignalsRequestItemDecisions) Validate(formats strfmt.Registry) error {
    24  	var res []error
    25  
    26  	for i := 0; i < len(m); i++ {
    27  		if swag.IsZero(m[i]) { // not required
    28  			continue
    29  		}
    30  
    31  		if m[i] != nil {
    32  			if err := m[i].Validate(formats); err != nil {
    33  				if ve, ok := err.(*errors.Validation); ok {
    34  					return ve.ValidateName(strconv.Itoa(i))
    35  				} else if ce, ok := err.(*errors.CompositeError); ok {
    36  					return ce.ValidateName(strconv.Itoa(i))
    37  				}
    38  				return err
    39  			}
    40  		}
    41  
    42  	}
    43  
    44  	if len(res) > 0 {
    45  		return errors.CompositeValidationError(res...)
    46  	}
    47  	return nil
    48  }
    49  
    50  // ContextValidate validate this add signals request item decisions based on the context it is used
    51  func (m AddSignalsRequestItemDecisions) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    52  	var res []error
    53  
    54  	for i := 0; i < len(m); i++ {
    55  
    56  		if m[i] != nil {
    57  			if err := m[i].ContextValidate(ctx, formats); err != nil {
    58  				if ve, ok := err.(*errors.Validation); ok {
    59  					return ve.ValidateName(strconv.Itoa(i))
    60  				} else if ce, ok := err.(*errors.CompositeError); ok {
    61  					return ce.ValidateName(strconv.Itoa(i))
    62  				}
    63  				return err
    64  			}
    65  		}
    66  
    67  	}
    68  
    69  	if len(res) > 0 {
    70  		return errors.CompositeValidationError(res...)
    71  	}
    72  	return nil
    73  }