README ¶
filter
import "github.com/greenbone/opensight-golang-libraries/pkg/query/filter"
Index
- Variables
- func AggregateMetricNames() []string
- func CompareOperatorNames() []string
- func ControlTypeNames() []string
- func LogicOperatorNames() []string
- func NewInvalidFilterFieldError(format string, value ...any) error
- func ValidateFilter(request *Request, requestOptions []RequestOption) error
- type AggregateMetric
- func ParseAggregateMetric(name string) (AggregateMetric, error)
- func (x AggregateMetric) IsValid() bool
- func (x AggregateMetric) MarshalText() ([]byte, error)
- func (x *AggregateMetric) Scan(value interface{}) (err error)
- func (x AggregateMetric) String() string
- func (x *AggregateMetric) UnmarshalText(text []byte) error
- func (x AggregateMetric) Value() (driver.Value, error)
- type CompareOperator
- func ParseCompareOperator(name string) (CompareOperator, error)
- func (x CompareOperator) IsValid() bool
- func (x CompareOperator) MarshalText() ([]byte, error)
- func (x *CompareOperator) Scan(value interface{}) (err error)
- func (x CompareOperator) String() string
- func (x *CompareOperator) UnmarshalText(text []byte) error
- func (x CompareOperator) Value() (driver.Value, error)
- type ControlType
- func ParseControlType(name string) (ControlType, error)
- func (x ControlType) IsValid() bool
- func (x ControlType) MarshalText() ([]byte, error)
- func (x *ControlType) Scan(value interface{}) (err error)
- func (x ControlType) String() string
- func (x *ControlType) UnmarshalText(text []byte) error
- func (x ControlType) Value() (driver.Value, error)
- type InvalidFilterFieldError
- type LogicOperator
- func ParseLogicOperator(name string) (LogicOperator, error)
- func (x LogicOperator) IsValid() bool
- func (x LogicOperator) MarshalText() ([]byte, error)
- func (x *LogicOperator) Scan(value interface{}) (err error)
- func (x LogicOperator) String() string
- func (x *LogicOperator) UnmarshalText(text []byte) error
- func (x LogicOperator) Value() (driver.Value, error)
- type ReadableValue
- type Request
- type RequestField
- type RequestOption
- type RequestOptionType
- type UuidValidationError
- type ValidationError
Variables
var ErrInvalidAggregateMetric = fmt.Errorf("not a valid AggregateMetric, try [%s]", strings.Join(_AggregateMetricNames, ", "))
var ErrInvalidCompareOperator = fmt.Errorf("not a valid CompareOperator, try [%s]", strings.Join(_CompareOperatorNames, ", "))
var ErrInvalidControlType = fmt.Errorf("not a valid ControlType, try [%s]", strings.Join(_ControlTypeNames, ", "))
var ErrInvalidLogicOperator = fmt.Errorf("not a valid LogicOperator, try [%s]", strings.Join(_LogicOperatorNames, ", "))
func AggregateMetricNames
func AggregateMetricNames() []string
AggregateMetricNames returns a list of possible string values of AggregateMetric.
func CompareOperatorNames
func CompareOperatorNames() []string
CompareOperatorNames returns a list of possible string values of CompareOperator.
func ControlTypeNames
func ControlTypeNames() []string
ControlTypeNames returns a list of possible string values of ControlType.
func LogicOperatorNames
func LogicOperatorNames() []string
LogicOperatorNames returns a list of possible string values of LogicOperator.
func NewInvalidFilterFieldError
func NewInvalidFilterFieldError(format string, value ...any) error
func ValidateFilter
func ValidateFilter(request *Request, requestOptions []RequestOption) error
ValidateFilter validates the filter in the request
type AggregateMetric
AggregateMetric ENUM(
sum
min
max
avg
valueCount
)
type AggregateMetric string
const (
// AggregateMetricSum is a AggregateMetric of type sum.
AggregateMetricSum AggregateMetric = "sum"
// AggregateMetricMin is a AggregateMetric of type min.
AggregateMetricMin AggregateMetric = "min"
// AggregateMetricMax is a AggregateMetric of type max.
AggregateMetricMax AggregateMetric = "max"
// AggregateMetricAvg is a AggregateMetric of type avg.
AggregateMetricAvg AggregateMetric = "avg"
// AggregateMetricValueCount is a AggregateMetric of type valueCount.
AggregateMetricValueCount AggregateMetric = "valueCount"
)
func ParseAggregateMetric
func ParseAggregateMetric(name string) (AggregateMetric, error)
ParseAggregateMetric attempts to convert a string to a AggregateMetric.
func (AggregateMetric) IsValid
func (x AggregateMetric) IsValid() bool
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (AggregateMetric) MarshalText
func (x AggregateMetric) MarshalText() ([]byte, error)
MarshalText implements the text marshaller method.
func (*AggregateMetric) Scan
func (x *AggregateMetric) Scan(value interface{}) (err error)
Scan implements the Scanner interface.
func (AggregateMetric) String
func (x AggregateMetric) String() string
String implements the Stringer interface.
func (*AggregateMetric) UnmarshalText
func (x *AggregateMetric) UnmarshalText(text []byte) error
UnmarshalText implements the text unmarshaller method.
func (AggregateMetric) Value
func (x AggregateMetric) Value() (driver.Value, error)
Value implements the driver Valuer interface.
type CompareOperator
CompareOperator ENUM(
beginsWith
doesNotBeginWith
contains
doesNotContain
isNumberEqualTo
isEqualTo
isIpEqualTo
isStringEqualTo
isNotEqualTo
isNumberNotEqualTo
isIpNotEqualTo
isStringNotEqualTo
isGreaterThan
isGreaterThanOrEqualTo
isLessThan
isLessThanOrEqualTo
beforeDate
afterDate
exists
)
type CompareOperator string
const (
// CompareOperatorBeginsWith is a CompareOperator of type beginsWith.
CompareOperatorBeginsWith CompareOperator = "beginsWith"
// CompareOperatorDoesNotBeginWith is a CompareOperator of type doesNotBeginWith.
CompareOperatorDoesNotBeginWith CompareOperator = "doesNotBeginWith"
// CompareOperatorContains is a CompareOperator of type contains.
CompareOperatorContains CompareOperator = "contains"
// CompareOperatorDoesNotContain is a CompareOperator of type doesNotContain.
CompareOperatorDoesNotContain CompareOperator = "doesNotContain"
// CompareOperatorIsNumberEqualTo is a CompareOperator of type isNumberEqualTo.
CompareOperatorIsNumberEqualTo CompareOperator = "isNumberEqualTo"
// CompareOperatorIsEqualTo is a CompareOperator of type isEqualTo.
CompareOperatorIsEqualTo CompareOperator = "isEqualTo"
// CompareOperatorIsIpEqualTo is a CompareOperator of type isIpEqualTo.
CompareOperatorIsIpEqualTo CompareOperator = "isIpEqualTo"
// CompareOperatorIsStringEqualTo is a CompareOperator of type isStringEqualTo.
CompareOperatorIsStringEqualTo CompareOperator = "isStringEqualTo"
// CompareOperatorIsNotEqualTo is a CompareOperator of type isNotEqualTo.
CompareOperatorIsNotEqualTo CompareOperator = "isNotEqualTo"
// CompareOperatorIsNumberNotEqualTo is a CompareOperator of type isNumberNotEqualTo.
CompareOperatorIsNumberNotEqualTo CompareOperator = "isNumberNotEqualTo"
// CompareOperatorIsIpNotEqualTo is a CompareOperator of type isIpNotEqualTo.
CompareOperatorIsIpNotEqualTo CompareOperator = "isIpNotEqualTo"
// CompareOperatorIsStringNotEqualTo is a CompareOperator of type isStringNotEqualTo.
CompareOperatorIsStringNotEqualTo CompareOperator = "isStringNotEqualTo"
// CompareOperatorIsGreaterThan is a CompareOperator of type isGreaterThan.
CompareOperatorIsGreaterThan CompareOperator = "isGreaterThan"
// CompareOperatorIsGreaterThanOrEqualTo is a CompareOperator of type isGreaterThanOrEqualTo.
CompareOperatorIsGreaterThanOrEqualTo CompareOperator = "isGreaterThanOrEqualTo"
// CompareOperatorIsLessThan is a CompareOperator of type isLessThan.
CompareOperatorIsLessThan CompareOperator = "isLessThan"
// CompareOperatorIsLessThanOrEqualTo is a CompareOperator of type isLessThanOrEqualTo.
CompareOperatorIsLessThanOrEqualTo CompareOperator = "isLessThanOrEqualTo"
// CompareOperatorBeforeDate is a CompareOperator of type beforeDate.
CompareOperatorBeforeDate CompareOperator = "beforeDate"
// CompareOperatorAfterDate is a CompareOperator of type afterDate.
CompareOperatorAfterDate CompareOperator = "afterDate"
// CompareOperatorExists is a CompareOperator of type exists.
CompareOperatorExists CompareOperator = "exists"
)
func ParseCompareOperator
func ParseCompareOperator(name string) (CompareOperator, error)
ParseCompareOperator attempts to convert a string to a CompareOperator.
func (CompareOperator) IsValid
func (x CompareOperator) IsValid() bool
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (CompareOperator) MarshalText
func (x CompareOperator) MarshalText() ([]byte, error)
MarshalText implements the text marshaller method.
func (*CompareOperator) Scan
func (x *CompareOperator) Scan(value interface{}) (err error)
Scan implements the Scanner interface.
func (CompareOperator) String
func (x CompareOperator) String() string
String implements the Stringer interface.
func (*CompareOperator) UnmarshalText
func (x *CompareOperator) UnmarshalText(text []byte) error
UnmarshalText implements the text unmarshaller method.
func (CompareOperator) Value
func (x CompareOperator) Value() (driver.Value, error)
Value implements the driver Valuer interface.
type ControlType
ControlType ENUM(
bool
enum
float
integer
string
dateTime
uuid
autocomplete
)
type ControlType string
const (
// ControlTypeBool is a ControlType of type bool.
ControlTypeBool ControlType = "bool"
// ControlTypeEnum is a ControlType of type enum.
ControlTypeEnum ControlType = "enum"
// ControlTypeFloat is a ControlType of type float.
ControlTypeFloat ControlType = "float"
// ControlTypeInteger is a ControlType of type integer.
ControlTypeInteger ControlType = "integer"
// ControlTypeString is a ControlType of type string.
ControlTypeString ControlType = "string"
// ControlTypeDateTime is a ControlType of type dateTime.
ControlTypeDateTime ControlType = "dateTime"
// ControlTypeUuid is a ControlType of type uuid.
ControlTypeUuid ControlType = "uuid"
// ControlTypeAutocomplete is a ControlType of type autocomplete.
ControlTypeAutocomplete ControlType = "autocomplete"
)
func ParseControlType
func ParseControlType(name string) (ControlType, error)
ParseControlType attempts to convert a string to a ControlType.
func (ControlType) IsValid
func (x ControlType) IsValid() bool
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (ControlType) MarshalText
func (x ControlType) MarshalText() ([]byte, error)
MarshalText implements the text marshaller method.
func (*ControlType) Scan
func (x *ControlType) Scan(value interface{}) (err error)
Scan implements the Scanner interface.
func (ControlType) String
func (x ControlType) String() string
String implements the Stringer interface.
func (*ControlType) UnmarshalText
func (x *ControlType) UnmarshalText(text []byte) error
UnmarshalText implements the text unmarshaller method.
func (ControlType) Value
func (x ControlType) Value() (driver.Value, error)
Value implements the driver Valuer interface.
type InvalidFilterFieldError
type InvalidFilterFieldError struct {
// contains filtered or unexported fields
}
func (*InvalidFilterFieldError) Error
func (i *InvalidFilterFieldError) Error() string
type LogicOperator
LogicOperator ENUM(
and
or
)
type LogicOperator string
const (
// LogicOperatorAnd is a LogicOperator of type and.
LogicOperatorAnd LogicOperator = "and"
// LogicOperatorOr is a LogicOperator of type or.
LogicOperatorOr LogicOperator = "or"
)
func ParseLogicOperator
func ParseLogicOperator(name string) (LogicOperator, error)
ParseLogicOperator attempts to convert a string to a LogicOperator.
func (LogicOperator) IsValid
func (x LogicOperator) IsValid() bool
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (LogicOperator) MarshalText
func (x LogicOperator) MarshalText() ([]byte, error)
MarshalText implements the text marshaller method.
func (*LogicOperator) Scan
func (x *LogicOperator) Scan(value interface{}) (err error)
Scan implements the Scanner interface.
func (LogicOperator) String
func (x LogicOperator) String() string
String implements the Stringer interface.
func (*LogicOperator) UnmarshalText
func (x *LogicOperator) UnmarshalText(text []byte) error
UnmarshalText implements the text unmarshaller method.
func (LogicOperator) Value
func (x LogicOperator) Value() (driver.Value, error)
Value implements the driver Valuer interface.
type ReadableValue
ReadableValue is a generic type that represents a human-readable value with a corresponding backend value. It has two fields: `Label` (the human-readable form of the value) and `Value` (the value for the backend).
type ReadableValue[T any] struct {
// Label is the human-readable form of the value
Label string `json:"label"`
// Value is the value for the backend
Value T `json:"value"`
}
type Request
Request is a struct representing a filter request. Operator is the logic operator used for the request. Fields is a slice of RequestField, representing the fields to be used for the filtering.
type Request struct {
Operator LogicOperator `json:"operator" binding:"required"`
Fields []RequestField `json:"fields" binding:"dive"`
}
type RequestField
RequestField represents a field in a request Field Name: The name of the field Field Keys: Sequence of keys of a nested key structure - only used for fields with a nested structure. Example: Tag -> Name: ABC (which would be represented as []string{"Tag", "Name: ABC"} ) Field Operator: The comparison operator for the field Field Value: The value of the field, which can be a list of values or a single value
type RequestField struct {
Name string `json:"name" binding:"required"`
Keys []string `json:"keys"`
Operator CompareOperator `json:"operator" binding:"required"`
// Value can be a list of values or a value
Value any `json:"value" binding:"required"`
}
type RequestOption
RequestOption configures a field for validation
Name: The name of the option Control: The type of control for the option Operators: The list of comparison operators for the option Values: The possible values for the option MultiSelect: Indicates whether the option supports multiple selections
type RequestOption struct {
Name ReadableValue[string]
Control RequestOptionType
Operators []ReadableValue[CompareOperator]
Values []string
MultiSelect bool
}
type RequestOptionType
RequestOptionType configures the type of control for a field in a request option.
type RequestOptionType struct {
Type ControlType `json:"type" enums:"string,float,integer,enum,bool"`
}
type UuidValidationError
type UuidValidationError struct {
// contains filtered or unexported fields
}
func NewUuidValidationError
func NewUuidValidationError(format string, value ...any) *UuidValidationError
func (*UuidValidationError) Error
func (v *UuidValidationError) Error() string
type ValidationError
type ValidationError struct {
// contains filtered or unexported fields
}
func NewValidationError
func NewValidationError(format string, value ...any) *ValidationError
func (*ValidationError) Error
func (v *ValidationError) Error() string
Generated by gomarkdoc
License
Copyright (C) 2022-2023 [Greenbone AG][Greenbone AG]
Licensed under the GNU General Public License v3.0 or later.
Documentation ¶
Index ¶
- Variables
- func AggregateMetricNames() []string
- func CompareOperatorNames() []string
- func ControlTypeNames() []string
- func LogicOperatorNames() []string
- func NewInvalidFilterFieldError(format string, value ...any) error
- func ValidateFilter(request *Request, requestOptions []RequestOption) error
- type AggregateMetric
- func (x AggregateMetric) IsValid() bool
- func (x AggregateMetric) MarshalText() ([]byte, error)
- func (x *AggregateMetric) Scan(value interface{}) (err error)
- func (x AggregateMetric) String() string
- func (x *AggregateMetric) UnmarshalText(text []byte) error
- func (x AggregateMetric) Value() (driver.Value, error)
- type CompareOperator
- func (x CompareOperator) IsValid() bool
- func (x CompareOperator) MarshalText() ([]byte, error)
- func (x *CompareOperator) Scan(value interface{}) (err error)
- func (x CompareOperator) String() string
- func (x *CompareOperator) UnmarshalText(text []byte) error
- func (x CompareOperator) Value() (driver.Value, error)
- type ControlType
- type InvalidFilterFieldError
- type LogicOperator
- type ReadableValue
- type Request
- type RequestField
- type RequestOption
- type RequestOptionType
- type UuidValidationError
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidAggregateMetric = fmt.Errorf("not a valid AggregateMetric, try [%s]", strings.Join(_AggregateMetricNames, ", "))
var ErrInvalidCompareOperator = fmt.Errorf("not a valid CompareOperator, try [%s]", strings.Join(_CompareOperatorNames, ", "))
var ErrInvalidControlType = fmt.Errorf("not a valid ControlType, try [%s]", strings.Join(_ControlTypeNames, ", "))
var ErrInvalidLogicOperator = fmt.Errorf("not a valid LogicOperator, try [%s]", strings.Join(_LogicOperatorNames, ", "))
Functions ¶
func AggregateMetricNames ¶
func AggregateMetricNames() []string
AggregateMetricNames returns a list of possible string values of AggregateMetric.
func CompareOperatorNames ¶
func CompareOperatorNames() []string
CompareOperatorNames returns a list of possible string values of CompareOperator.
func ControlTypeNames ¶
func ControlTypeNames() []string
ControlTypeNames returns a list of possible string values of ControlType.
func LogicOperatorNames ¶
func LogicOperatorNames() []string
LogicOperatorNames returns a list of possible string values of LogicOperator.
func ValidateFilter ¶
func ValidateFilter(request *Request, requestOptions []RequestOption) error
ValidateFilter validates the filter in the request
Types ¶
type AggregateMetric ¶
type AggregateMetric string
AggregateMetric ENUM(
sum min max avg valueCount
)
const ( // AggregateMetricSum is a AggregateMetric of type sum. AggregateMetricSum AggregateMetric = "sum" // AggregateMetricMin is a AggregateMetric of type min. AggregateMetricMin AggregateMetric = "min" // AggregateMetricMax is a AggregateMetric of type max. AggregateMetricMax AggregateMetric = "max" // AggregateMetricAvg is a AggregateMetric of type avg. AggregateMetricAvg AggregateMetric = "avg" // AggregateMetricValueCount is a AggregateMetric of type valueCount. AggregateMetricValueCount AggregateMetric = "valueCount" )
func ParseAggregateMetric ¶
func ParseAggregateMetric(name string) (AggregateMetric, error)
ParseAggregateMetric attempts to convert a string to a AggregateMetric.
func (AggregateMetric) IsValid ¶
func (x AggregateMetric) IsValid() bool
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (AggregateMetric) MarshalText ¶
func (x AggregateMetric) MarshalText() ([]byte, error)
MarshalText implements the text marshaller method.
func (*AggregateMetric) Scan ¶
func (x *AggregateMetric) Scan(value interface{}) (err error)
Scan implements the Scanner interface.
func (AggregateMetric) String ¶
func (x AggregateMetric) String() string
String implements the Stringer interface.
func (*AggregateMetric) UnmarshalText ¶
func (x *AggregateMetric) UnmarshalText(text []byte) error
UnmarshalText implements the text unmarshaller method.
type CompareOperator ¶
type CompareOperator string
CompareOperator ENUM(
beginsWith doesNotBeginWith contains doesNotContain isNumberEqualTo isEqualTo isIpEqualTo isStringEqualTo isNotEqualTo isNumberNotEqualTo isIpNotEqualTo isStringNotEqualTo isGreaterThan isGreaterThanOrEqualTo isLessThan isLessThanOrEqualTo beforeDate afterDate exists
)
const ( // CompareOperatorBeginsWith is a CompareOperator of type beginsWith. CompareOperatorBeginsWith CompareOperator = "beginsWith" // CompareOperatorDoesNotBeginWith is a CompareOperator of type doesNotBeginWith. CompareOperatorDoesNotBeginWith CompareOperator = "doesNotBeginWith" // CompareOperatorContains is a CompareOperator of type contains. CompareOperatorContains CompareOperator = "contains" // CompareOperatorDoesNotContain is a CompareOperator of type doesNotContain. CompareOperatorDoesNotContain CompareOperator = "doesNotContain" // CompareOperatorIsNumberEqualTo is a CompareOperator of type isNumberEqualTo. CompareOperatorIsNumberEqualTo CompareOperator = "isNumberEqualTo" // CompareOperatorIsEqualTo is a CompareOperator of type isEqualTo. CompareOperatorIsEqualTo CompareOperator = "isEqualTo" // CompareOperatorIsIpEqualTo is a CompareOperator of type isIpEqualTo. CompareOperatorIsIpEqualTo CompareOperator = "isIpEqualTo" // CompareOperatorIsStringEqualTo is a CompareOperator of type isStringEqualTo. CompareOperatorIsStringEqualTo CompareOperator = "isStringEqualTo" // CompareOperatorIsNotEqualTo is a CompareOperator of type isNotEqualTo. CompareOperatorIsNotEqualTo CompareOperator = "isNotEqualTo" // CompareOperatorIsNumberNotEqualTo is a CompareOperator of type isNumberNotEqualTo. CompareOperatorIsNumberNotEqualTo CompareOperator = "isNumberNotEqualTo" // CompareOperatorIsIpNotEqualTo is a CompareOperator of type isIpNotEqualTo. CompareOperatorIsIpNotEqualTo CompareOperator = "isIpNotEqualTo" // CompareOperatorIsStringNotEqualTo is a CompareOperator of type isStringNotEqualTo. CompareOperatorIsStringNotEqualTo CompareOperator = "isStringNotEqualTo" // CompareOperatorIsGreaterThan is a CompareOperator of type isGreaterThan. CompareOperatorIsGreaterThan CompareOperator = "isGreaterThan" // CompareOperatorIsGreaterThanOrEqualTo is a CompareOperator of type isGreaterThanOrEqualTo. CompareOperatorIsGreaterThanOrEqualTo CompareOperator = "isGreaterThanOrEqualTo" // CompareOperatorIsLessThan is a CompareOperator of type isLessThan. CompareOperatorIsLessThan CompareOperator = "isLessThan" // CompareOperatorIsLessThanOrEqualTo is a CompareOperator of type isLessThanOrEqualTo. CompareOperatorIsLessThanOrEqualTo CompareOperator = "isLessThanOrEqualTo" // CompareOperatorBeforeDate is a CompareOperator of type beforeDate. CompareOperatorBeforeDate CompareOperator = "beforeDate" // CompareOperatorAfterDate is a CompareOperator of type afterDate. CompareOperatorAfterDate CompareOperator = "afterDate" // CompareOperatorExists is a CompareOperator of type exists. CompareOperatorExists CompareOperator = "exists" )
func ParseCompareOperator ¶
func ParseCompareOperator(name string) (CompareOperator, error)
ParseCompareOperator attempts to convert a string to a CompareOperator.
func (CompareOperator) IsValid ¶
func (x CompareOperator) IsValid() bool
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (CompareOperator) MarshalText ¶
func (x CompareOperator) MarshalText() ([]byte, error)
MarshalText implements the text marshaller method.
func (*CompareOperator) Scan ¶
func (x *CompareOperator) Scan(value interface{}) (err error)
Scan implements the Scanner interface.
func (CompareOperator) String ¶
func (x CompareOperator) String() string
String implements the Stringer interface.
func (*CompareOperator) UnmarshalText ¶
func (x *CompareOperator) UnmarshalText(text []byte) error
UnmarshalText implements the text unmarshaller method.
type ControlType ¶
type ControlType string
ControlType ENUM(
bool enum float integer string dateTime uuid autocomplete
)
const ( // ControlTypeBool is a ControlType of type bool. ControlTypeBool ControlType = "bool" // ControlTypeEnum is a ControlType of type enum. ControlTypeEnum ControlType = "enum" // ControlTypeFloat is a ControlType of type float. ControlTypeFloat ControlType = "float" // ControlTypeInteger is a ControlType of type integer. ControlTypeInteger ControlType = "integer" // ControlTypeString is a ControlType of type string. ControlTypeString ControlType = "string" // ControlTypeDateTime is a ControlType of type dateTime. ControlTypeDateTime ControlType = "dateTime" // ControlTypeUuid is a ControlType of type uuid. ControlTypeUuid ControlType = "uuid" // ControlTypeAutocomplete is a ControlType of type autocomplete. ControlTypeAutocomplete ControlType = "autocomplete" )
func ParseControlType ¶
func ParseControlType(name string) (ControlType, error)
ParseControlType attempts to convert a string to a ControlType.
func (ControlType) IsValid ¶
func (x ControlType) IsValid() bool
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (ControlType) MarshalText ¶
func (x ControlType) MarshalText() ([]byte, error)
MarshalText implements the text marshaller method.
func (*ControlType) Scan ¶
func (x *ControlType) Scan(value interface{}) (err error)
Scan implements the Scanner interface.
func (ControlType) String ¶
func (x ControlType) String() string
String implements the Stringer interface.
func (*ControlType) UnmarshalText ¶
func (x *ControlType) UnmarshalText(text []byte) error
UnmarshalText implements the text unmarshaller method.
type InvalidFilterFieldError ¶
type InvalidFilterFieldError struct {
// contains filtered or unexported fields
}
func (*InvalidFilterFieldError) Error ¶
func (i *InvalidFilterFieldError) Error() string
type LogicOperator ¶
type LogicOperator string
LogicOperator ENUM(
and or
)
const ( // LogicOperatorAnd is a LogicOperator of type and. LogicOperatorAnd LogicOperator = "and" // LogicOperatorOr is a LogicOperator of type or. LogicOperatorOr LogicOperator = "or" )
func ParseLogicOperator ¶
func ParseLogicOperator(name string) (LogicOperator, error)
ParseLogicOperator attempts to convert a string to a LogicOperator.
func (LogicOperator) IsValid ¶
func (x LogicOperator) IsValid() bool
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (LogicOperator) MarshalText ¶
func (x LogicOperator) MarshalText() ([]byte, error)
MarshalText implements the text marshaller method.
func (*LogicOperator) Scan ¶
func (x *LogicOperator) Scan(value interface{}) (err error)
Scan implements the Scanner interface.
func (LogicOperator) String ¶
func (x LogicOperator) String() string
String implements the Stringer interface.
func (*LogicOperator) UnmarshalText ¶
func (x *LogicOperator) UnmarshalText(text []byte) error
UnmarshalText implements the text unmarshaller method.
type ReadableValue ¶
type ReadableValue[T any] struct { // Label is the human-readable form of the value Label string `json:"label"` // Value is the value for the backend Value T `json:"value"` }
ReadableValue is a generic type that represents a human-readable value with a corresponding backend value. It has two fields: `Label` (the human-readable form of the value) and `Value` (the value for the backend).
type Request ¶
type Request struct { Operator LogicOperator `json:"operator" binding:"required"` Fields []RequestField `json:"fields" binding:"dive"` }
Request is a struct representing a filter request. Operator is the logic operator used for the request. Fields is a slice of RequestField, representing the fields to be used for the filtering.
type RequestField ¶
type RequestField struct { Name string `json:"name" binding:"required"` Keys []string `json:"keys"` Operator CompareOperator `json:"operator" binding:"required"` // Value can be a list of values or a value Value any `json:"value" binding:"required"` }
RequestField represents a field in a request Field Name: The name of the field Field Keys: Sequence of keys of a nested key structure - only used for fields with a nested structure. Example: Tag -> Name: ABC (which would be represented as []string{"Tag", "Name: ABC"} ) Field Operator: The comparison operator for the field Field Value: The value of the field, which can be a list of values or a single value
type RequestOption ¶
type RequestOption struct { Name ReadableValue[string] Control RequestOptionType Operators []ReadableValue[CompareOperator] Values []string MultiSelect bool }
RequestOption configures a field for validation
Name: The name of the option Control: The type of control for the option Operators: The list of comparison operators for the option Values: The possible values for the option MultiSelect: Indicates whether the option supports multiple selections
type RequestOptionType ¶
type RequestOptionType struct {
Type ControlType `json:"type" enums:"string,float,integer,enum,bool"`
}
RequestOptionType configures the type of control for a field in a request option.
type UuidValidationError ¶
type UuidValidationError struct {
// contains filtered or unexported fields
}
func NewUuidValidationError ¶
func NewUuidValidationError(format string, value ...any) *UuidValidationError
func (*UuidValidationError) Error ¶
func (v *UuidValidationError) Error() string
type ValidationError ¶
type ValidationError struct {
// contains filtered or unexported fields
}
func NewValidationError ¶
func NewValidationError(format string, value ...any) *ValidationError
func (*ValidationError) Error ¶
func (v *ValidationError) Error() string