validateMessage static method
Validates a message object before sending.
message
is the message to validate.
Returns true if the message is valid.
Throws MessageException if the message is invalid.
Implementation
static bool validateMessage(Message message) {
// Validate recipient
validatePhoneNumber(message.recipient);
// Check if message content is valid according to its type
if (!message.isValid()) {
throw MessageException.invalidContent(
'Invalid message content for type ${message.type}.',
);
}
return true;
}