straywild/messages/bottle_message_data.gd

20 lines
535 B
GDScript

class_name BottleMessageData
extends Resource
const MAX_MESSAGE_ID_LENGTH: int = 96
const MAX_BODY_LENGTH: int = 4096
@export var message_id: StringName
@export_multiline var body: String = ""
@export var active: bool = true
func is_valid() -> bool:
var normalized_id: String = String(message_id).strip_edges()
return (
not normalized_id.is_empty()
and normalized_id.length() <= MAX_MESSAGE_ID_LENGTH
and normalized_id == String(message_id)
and not body.strip_edges().is_empty()
and body.length() <= MAX_BODY_LENGTH
)