Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
@JsonSubTypes.Type(value = Image.class, name = Image.TYPE),
@JsonSubTypes.Type(value = Input.class, name = Input.TYPE),
@JsonSubTypes.Type(value = Section.class, name = Section.TYPE),
@JsonSubTypes.Type(value = Markdown.class, name = Markdown.TYPE),
}
)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public enum BlockElementLengthLimits {
MAX_OPTION_GROUP_LABEL_LENGTH(75),
MAX_OPTION_VALUE_LENGTH(75),
MAX_CHECKBOXES_NUMBER(10),
MAX_RADIO_BUTTONS_NUMBER(10);
MAX_RADIO_BUTTONS_NUMBER(10),
MAX_MARKDOWN_LENGTH(12000);

private final int limit;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.hubspot.slack.client.models.blocks;

import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.google.common.base.Preconditions;
import com.hubspot.immutables.style.HubSpotStyle;
import org.immutables.value.Value.Check;
import org.immutables.value.Value.Derived;
import org.immutables.value.Value.Immutable;
import org.immutables.value.Value.Parameter;

@Immutable
@HubSpotStyle
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public interface MarkdownIF extends Block {
String TYPE = "markdown";

/**
* The type of block. For a markdown block, type is always markdown.
* <br/><br/>
* Type: String
* <br/>
* Required: true
*/
@Override
@Derived
default String getType() {
return TYPE;
}

/**
* The standard markdown-formatted text. Limit 12,000 characters max.
* <br/><br/>
* Type: String
* <br/>
* Required: true
*/
@Parameter
String getText();

@Check
default void check() {
Preconditions.checkState(
getText().length() < BlockElementLengthLimits.MAX_MARKDOWN_LENGTH.getLimit(),
"Text length must be less than " +
BlockElementLengthLimits.MAX_MARKDOWN_LENGTH.getLimit() +
" characters"
);
}
}