summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/slack-go/slack/block_object.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/slack-go/slack/block_object.go')
-rw-r--r--vendor/github.com/slack-go/slack/block_object.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/vendor/github.com/slack-go/slack/block_object.go b/vendor/github.com/slack-go/slack/block_object.go
index d17806ca..5ced7f92 100644
--- a/vendor/github.com/slack-go/slack/block_object.go
+++ b/vendor/github.com/slack-go/slack/block_object.go
@@ -2,6 +2,7 @@ package slack
import (
"encoding/json"
+ "errors"
)
// Block Objects are also known as Composition Objects
@@ -135,6 +136,20 @@ func (s TextBlockObject) MixedElementType() MixedElementType {
return MixedElementText
}
+// Validate checks if TextBlockObject has valid values
+func (s TextBlockObject) Validate() error {
+ if s.Type != "plain_text" && s.Type != "mrkdwn" {
+ return errors.New("type must be either of plain_text or mrkdwn")
+ }
+
+ // https://github.com/slack-go/slack/issues/881
+ if s.Type == "mrkdwn" && s.Emoji {
+ return errors.New("emoji cannot be true in mrkdown")
+ }
+
+ return nil
+}
+
// NewTextBlockObject returns an instance of a new Text Block Object
func NewTextBlockObject(elementType, text string, emoji, verbatim bool) *TextBlockObject {
return &TextBlockObject{