// Validate checks whether query field values go out the bounds of
// sanity or not.
// First parameter should be filter key and value checking func,
// second - sort key checking func.
Validate checks whether query field values go out the bounds of
sanity or not.
First parameter should be filter key and value checking func,
second - sort key checking func.
// Validate checks whether query field values go out the bounds of // sanity or not . // First parameter should be filter key and value checking func // second - sort key checking func .
func (q Query) Validate(fck func(k, v string) error, sck func(k string) error) error {
	if err := fck(q.FilterBy, q.FilterVal); err != nil {
		return err
	}
	if err := sck(q.SortBy); err != nil {
		return err
	}
	if q.Limit < 1 {
		return NewError(nil, http.StatusBadRequest, "invalid limit")
	}
	if q.Page < 1 {
		return NewError(nil, http.StatusBadRequest, "invalid page")
	}
	return nil
}
func ( q Query ) Validate ( fck func ( k , v string ) error , sck func ( k string ) error ) error { if err := fck ( q . FilterBy , q . FilterVal ) ; err != nil { return err } if err := sck ( q . SortBy ) ; err != nil { return err } if q . Limit < 1 { return NewError ( nil , http . StatusBadRequest , " " ) } if q . Page < 1 { return NewError ( nil , http . StatusBadRequest , " " ) } return nil }
Validate checks whether query field values go out the bounds of
sanity or not.
Validate checks whether query field values go out the bounds of sanity or not .