Documentation
¶
Index ¶
- func CreateMoneyNullString(s string) (sql.NullString, error)
- func CreateTextNullString(s string) sql.NullString
- type QueryService
- type QueryValidationError
- type Service
- func (qv *Service) BuildSqlQuery(queries map[string]string, accountID string) (string, []any, error)
- func (qv *Service) ValidateParamValue(value, expectedType string) (bool, error)
- func (qv *Service) ValidateQuery(queries url.Values, rules map[string]string) (map[string]string, []QueryValidationError)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateMoneyNullString ¶
func CreateMoneyNullString(s string) (sql.NullString, error)
Turns a given string into SQL type NullString, so it can be inserted into possible Null fields in database - this version handles strings that will be turned into NUMERIC(16, 2) type
func CreateTextNullString ¶
func CreateTextNullString(s string) sql.NullString
This version will handle text NullStrings
Types ¶
type QueryService ¶
type QueryService interface {
ValidateParamValue(value, expectedType string) (bool, error)
ValidateQuery(queries url.Values, rules map[string]string) (map[string]string, []QueryValidationError)
BuildSqlQuery(queries map[string]string, accountID string) (string, []any, error)
}
URL Query service interface
type QueryValidationError ¶
type QueryValidationError struct {
Parameter string `json:"parameter"`
Value string `json:"value"`
Message string `json:"message"`
}
Represents an error related to query parameter validation
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Responsible for validating query parameters based on their type. Holds map of type validators, where key is the type, and value is a function that validates the string value
func (*Service) BuildSqlQuery ¶
func (qv *Service) BuildSqlQuery(queries map[string]string, accountID string) (string, []any, error)
Builds an SQL query for transactions based on optional query arguments
func (*Service) ValidateParamValue ¶
Validates a query parameter's value based on its expected type. - value: Value of parameter to validate - expectedType: Expected data type of query parameter Returns true if value passes validation or no validator exists for expected type
func (*Service) ValidateQuery ¶
func (qv *Service) ValidateQuery(queries url.Values, rules map[string]string) (map[string]string, []QueryValidationError)
Validates query parameters based on predefined rules. Rules is a map of expected query parameters and their expected types. Returns slice of QueryValidationError if validation fails