Problem
The poll schema in messages/ai/schemas/AIMessagePollSchema.js accepts any numeric selectableCount, including zero, negative values, fractions, and values larger than the number of options. Invalid values can be rejected by WhatsApp/Baileys or create polls that do not behave as intended.
Expected behavior
A generated poll should always have a positive integer selection count that does not exceed the number of available options.
Suggested direction
Add numeric constraints to the schema and, if needed, a cross-field validation step that compares selectableCount with values.length.
Acceptance criteria
selectableCount must be an integer of at least 1.
- It cannot exceed the number of poll options.
- Invalid values are rejected before
sock.sendMessage is called.
- Valid single-select and multi-select polls continue to work.
Problem
The poll schema in
messages/ai/schemas/AIMessagePollSchema.jsaccepts any numericselectableCount, including zero, negative values, fractions, and values larger than the number of options. Invalid values can be rejected by WhatsApp/Baileys or create polls that do not behave as intended.Expected behavior
A generated poll should always have a positive integer selection count that does not exceed the number of available options.
Suggested direction
Add numeric constraints to the schema and, if needed, a cross-field validation step that compares
selectableCountwithvalues.length.Acceptance criteria
selectableCountmust be an integer of at least 1.sock.sendMessageis called.