Skip to content

Commit 77a125a

Browse files
Fix "InputBlock" hint validation (#726)
* 🚑 Accept correct type at "Option" object * 🚑 Fix hint check at "InputBlock" * 🚑 Undo "Optional" API changes * ☔ Test "InputBlock.hint" validation
1 parent c09eb25 commit 77a125a

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

slack/web/classes/blocks.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,11 @@ def _validate_label_length(self):
310310

311311
@JsonValidator(f"hint attribute cannot exceed {hint_max_length} characters")
312312
def _validate_hint_length(self):
313-
return self.hint is None or len(self.hint) <= self.hint_max_length
313+
return (
314+
self.hint is None
315+
or self.hint.text is None
316+
or len(self.hint.text) <= self.label_max_length
317+
)
314318

315319
@JsonValidator(
316320
(

tests/web/classes/test_blocks.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,23 @@ def test_document(self):
584584
"text": "Label",
585585
"emoji": True
586586
}
587-
}
587+
},
588+
{
589+
"type": "input",
590+
"element": {
591+
"type": "plain_text_input",
592+
},
593+
"label": {
594+
"type": "plain_text",
595+
"text": "Label",
596+
"emoji": True,
597+
},
598+
"hint": {
599+
"type": "plain_text",
600+
"text": "some hint",
601+
"emoji": True,
602+
},
603+
},
588604
]
589605
for input in blocks:
590606
self.assertDictEqual(input, InputBlock(**input).to_dict())

0 commit comments

Comments
 (0)