Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Boolean ¶
type Boolean struct {
// contains filtered or unexported fields
}
Boolean validates boolean values and returns a Filter. The Filter returned will be true or false.
func NewBoolean ¶
NewBoolean returns a new Boolean instance.
func (*Boolean) Present ¶
Present gets a url and check if a boolean filter is present, if it's present validates if its value are true or false. Returns a Filter with the applied value or nil is not present.
func (*Boolean) WithValues ¶
WithValues returns the filter with true and false values.
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder validates filters from url.Values and returns Filters with the value found. If not filters were found, it returns nil.
func NewDecoder ¶
func NewDecoder(params url.Values, decoders ...FilterDecoder) *Decoder
NewDecoder returns a new Decoder instance.
type Filter ¶
type Filter struct { ID string `json:"id"` Description string `json:"description"` Type string `json:"type"` Values []Value `json:"values"` }
Filter struct that represent a filter
func (Filter) MarshalJSON ¶
MarshalJSON supports json.Marshaler interface
type FilterDecoder ¶
type FilterDecoder interface { // Present gets the url params and check if a filter is present within them, // if it's present validates if its value is valid. // Returns a Filter with the applied value or nil is not present. Present(url.Values) *Filter // WithValues returns a filter with all their posible values. WithValues() *Filter }
FilterDecoder interface to validate and returns Filter's.
type Filtering ¶
type Filtering struct { Filters []Filter `json:"filters,omitempty"` Available []Filter `json:"available,omitempty"` }
Filtering allows to filter a collection with the selected Filters and their selected values. The Available are all the possible Filters with all their possible values.
func (Filtering) MarshalJSON ¶
MarshalJSON supports json.Marshaler interface
type Text ¶
type Text struct {
// contains filtered or unexported fields
}
Text validates text values and returns a Filter with the value found. If not filters were found, it returns nil.
func (*Text) Present ¶
Present gets the url params and check if a text filter is present, if it's present validates its value meets one of filter values options. Returns a Filter with the applied value or nil is not present.
func (*Text) WithValues ¶
WithValues returns the filter with all their values.