Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions block_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ func (s TextBlockObject) MixedElementType() MixedElementType {

// 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")
Expand Down
18 changes: 18 additions & 0 deletions block_object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,24 @@ func TestValidateTextBlockObject(t *testing.T) {
},
expected: nil,
},
{
input: TextBlockObject{
Type: "mrkdwn",
Text: "testText",
Emoji: false,
Verbatim: false,
},
expected: nil,
},
{
input: TextBlockObject{
Type: "invalid",
Text: "testText",
Emoji: false,
Verbatim: false,
},
expected: errors.New("type must be either of plain_text or mrkdwn"),
},
{
input: TextBlockObject{
Type: "mrkdwn",
Expand Down