Documentation ¶
Index ¶
- Variables
- func Alert(code int, message string)
- func MapKeysToSlice[K comparable, V any](m map[K]V) []K
- func RequestValidator(request M, fields ...string) (IValidator, M)
- type DateTime
- type EmailAttachment
- type IConn
- type IRequest
- type ISubscription
- type IValidator
- type M
- type Money
- type P
- type Protected
- type Q
- type Real
- type Request
- type S
Constants ¶
This section is empty.
Variables ¶
var ( ErrCantReply = errors.New("uniform: no reply channel available") ErrTimeout = errors.New("uniform: timeout") )
A package level reusable error for chain timeouts
var Contains = func(haystack []string, needle string, caseSensitive bool) bool { return IndexOf(haystack, needle, caseSensitive) != -1 }
Contains checks if a string array contains a given string
var Filter = func(items, filters []string, caseSensitive bool) []string { if filters == nil || len(filters) <= 0 { return items } filteredItems := make([]string, 0) for _, item := range items { if Contains(filters, item, caseSensitive) { continue } filteredItems = append(filteredItems, item) } return filteredItems }
Filter trims the filterItems from the items array
var Hash = func(value interface{}, salt string) string { concatenatedData := []byte(fmt.Sprintf(`%s%v`, salt, value)) encoder := sha512.New() _, err := encoder.Write(concatenatedData) if err != nil { panic(err) } hashedData := encoder.Sum(nil) base64EncodedString := base64.StdEncoding.EncodeToString(hashedData) return base64EncodedString }
Hash generates a sha512 hash for the given value/salt combo
var IndexOf = func(haystack []string, needle string, caseSensitive bool) int { if caseSensitive { for i, item := range haystack { if item == needle { return i } } } else { lowNeedle := strings.ToLower(needle) for i, item := range haystack { if strings.ToLower(item) == lowNeedle { return i } } } return -1 }
IndexOf Gets the index of a string in an array of strings
var IsEmpty = func(value interface{}) bool { if value == nil || value == "" { return true } stringValue := strings.TrimSpace(fmt.Sprint(value)) if stringValue == "" || stringValue == "nil" || stringValue == "<nil>" { return true } if strings.HasPrefix(stringValue, "0001-01-01") { return true } return isEmpty(value) }
IsEmpty determines if a value is empty or not
var ParseRequest = func(data []byte) (Request, error) { var request Request if err := bson.Unmarshal(data, &request); err != nil { return request, err } switch value := request.Model.(type) { case primitive.Binary: request.Model = value.Data break } return request, nil }
ParseRequest Gets the index of a string in an array of strings
var ValidateDate = func(american bool, value interface{}) (bool, []string, time.Time) { panic("not yet implemented") }
var ValidateDateTime = func(american bool, value interface{}) (bool, []string, time.Time) { panic("not yet implemented") }
var ValidateEmail = func(value interface{}) (bool, []string, interface{}) { panic("not yet implemented") }
var ValidateIdentityNumber = func(country string, value interface{}) (bool, []string, interface{}) { panic("not yet implemented") }
var ValidateMaximumFloat = func(maximum float64, value interface{}) (bool, []string) { panic("not yet implemented") }
var ValidateMaximumInt = func(maximum int64, value interface{}) (bool, []string) { panic("not yet implemented") }
var ValidateMinimumFloat = func(minimum float64, value interface{}) (bool, []string) { panic("not yet implemented") }
var ValidateMinimumInt = func(minimum int64, value interface{}) (bool, []string) { panic("not yet implemented") }
var ValidateMobile = func(country string, value interface{}) (bool, []string, interface{}) { panic("not yet implemented") }
var ValidatePassportNumber = func(country string, value interface{}) (bool, []string, interface{}) { panic("not yet implemented") }
var ValidateRangeFloat = func(minimum, maximum float64, value interface{}) (bool, []string) { panic("not yet implemented") }
var ValidateRangeInt = func(minimum, maximum int64, value interface{}) (bool, []string) { panic("not yet implemented") }
Functions ¶
func Alert ¶
Trigger a panic in a specific format that will tell the api layer to respond with a specific error code
func MapKeysToSlice ¶
func MapKeysToSlice[K comparable, V any](m map[K]V) []K
MapKeysToSlice extract the keys of map as an array
func RequestValidator ¶
func RequestValidator(request M, fields ...string) (IValidator, M)
Types ¶
type EmailAttachment ¶
type IConn ¶
type IConn interface { Request(page diary.IPage, subj string, timeout time.Duration, request Request, scope S) error Publish(page diary.IPage, subj string, request Request) error ChainRequest(page diary.IPage, subj string, original IRequest, request Request, scope S) error ChainPublish(page diary.IPage, subj string, original IRequest, request Request) error Subscribe(rate time.Duration, subj string, scope S) (ISubscription, error) QueueSubscribe(rate time.Duration, subj, queue string, scope S) (ISubscription, error) GeneratePdf(p diary.IPage, timeout time.Duration, serviceId string, html []byte) []byte SendEmail(p diary.IPage, timeout time.Duration, serviceId, from, fromName, subject, body string, to ...string) SendEmailX(p diary.IPage, timeout time.Duration, serviceId, from, fromName, subject, body string, attachments []EmailAttachment, to ...string) SendSms(p diary.IPage, timeout time.Duration, serviceId, body string, to ...string) SendEmailTemplate(p diary.IPage, timeout time.Duration, asset func(string) []byte, serviceId, from, fromName, path string, vars M, to ...string) SendEmailTemplateX(p diary.IPage, timeout time.Duration, asset func(string) []byte, serviceId, from, fromName, path string, vars M, attachments []EmailAttachment, to ...string) SendSmsTemplate(p diary.IPage, timeout time.Duration, asset func(string) []byte, serviceId, path string, vars M, to ...string) // Populates model with the raw underlying connector which may be required by more advanced users Raw(model interface{}) Drain() error Close() }
A definition of the public functions for a connection interface
func ConnectorAwsEventBridge ¶
func ConnectorAzureEventGrid ¶
type IRequest ¶
type IRequest interface { Conn() IConn Read(interface{}) Parameters() P Context() M CanReply() bool Reply(Request) error ReplyContinue(Request, S) error Raw() Request Bytes() []byte Channel() string Timeout() time.Duration StartedAt() time.Time Remainder() time.Duration HasError() bool Error() string }
A definition of the public functions for a request interface
type ISubscription ¶
type ISubscription interface {
Unsubscribe() error
}
A definition of the public functions for a subscription interface
type IValidator ¶
type IValidator interface { Error(field string, errors ...string) Validate() Check() Q Required(document M, fields ...string) M MinimumInt(document M, minimum int64, fields ...string) M MaximumInt(document M, maximum int64, fields ...string) M MinimumFloat(document M, minimum float64, fields ...string) M MaximumFloat(document M, maximum float64, fields ...string) M RangeInt(document M, minimum, maximum int64, fields ...string) M RangeFloat(document M, minimum, maximum float64, fields ...string) M Mobile(country string, document M, minimum, maximum float64, fields ...string) M Email(country string, document M, minimum, maximum float64, fields ...string) M PassportNumber(country string, document M, minimum, maximum float64, fields ...string) M IdentityNumber(country string, document M, minimum, maximum float64, fields ...string) M Date(country string, document M, minimum, maximum float64, fields ...string) M DateTime(country string, document M, minimum, maximum float64, fields ...string) M }
A definition of the public functions for a request interface
func NewValidator ¶
func NewValidator() IValidator
type Protected ¶
func NewProtectedValue ¶
func NewProtectedValue(value interface{}) Protected