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 textContains isNumberEqualTo isEqualTo isIpEqualTo isStringEqualTo isStringCaseInsensitiveEqualTo isNotEqualTo isNumberNotEqualTo isIpNotEqualTo isStringNotEqualTo isGreaterThan isGreaterThanOrEqualTo isLessThan isLessThanOrEqualTo beforeDate afterDate exists isEqualToRating isNotEqualToRating isGreaterThanRating isLessThanRating isGreaterThanOrEqualToRating isLessThanOrEqualToRating betweenDates
)
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" // CompareOperatorTextContains is a CompareOperator of type textContains. CompareOperatorTextContains CompareOperator = "textContains" // 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" // CompareOperatorIsStringCaseInsensitiveEqualTo is a CompareOperator of type isStringCaseInsensitiveEqualTo. CompareOperatorIsStringCaseInsensitiveEqualTo CompareOperator = "isStringCaseInsensitiveEqualTo" // 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" // CompareOperatorIsEqualToRating is a CompareOperator of type isEqualToRating. CompareOperatorIsEqualToRating CompareOperator = "isEqualToRating" // CompareOperatorIsNotEqualToRating is a CompareOperator of type isNotEqualToRating. CompareOperatorIsNotEqualToRating CompareOperator = "isNotEqualToRating" // CompareOperatorIsGreaterThanRating is a CompareOperator of type isGreaterThanRating. CompareOperatorIsGreaterThanRating CompareOperator = "isGreaterThanRating" // CompareOperatorIsLessThanRating is a CompareOperator of type isLessThanRating. CompareOperatorIsLessThanRating CompareOperator = "isLessThanRating" // CompareOperatorIsGreaterThanOrEqualToRating is a CompareOperator of type isGreaterThanOrEqualToRating. CompareOperatorIsGreaterThanOrEqualToRating CompareOperator = "isGreaterThanOrEqualToRating" // CompareOperatorIsLessThanOrEqualToRating is a CompareOperator of type isLessThanOrEqualToRating. CompareOperatorIsLessThanOrEqualToRating CompareOperator = "isLessThanOrEqualToRating" // CompareOperatorBetweenDates is a CompareOperator of type betweenDates. CompareOperatorBetweenDates CompareOperator = "betweenDates" )
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,omitempty"` 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