Tiga helper
| API | Kapan dipakai |
|---|---|
| sesi.input(options) | Butuh object validation lengkap dan kontrol manual. |
| sesi.wajibInput(options) | Input required; error otomatis dibalas dan execution event berhenti. |
| sesi.opsionalInput(options) | Input optional + kata skip/lewati. |
Contoh nomor HP
js
const nomor = sesi.wajibInput({
tipe: "nomor_hp",
min: 10,
max: 15,
pesanSalah: "Nomor HP tidak valid."
})Contoh PDF
js
const pdf = sesi.wajibInput({
tipe: "dokumen",
mime: ["application/pdf"],
ekstensi: ["pdf"],
maxMb: 5,
minKb: 1,
captionWajib: false,
pesanSalah: "Kirim PDF maksimal 5 MB."
})Input optional
js
const lampiran = sesi.opsionalInput({
tipe: "media",
lewati: ["skip", "lewati"],
maxMb: 5
})
if (lampiran) {
sesi.simpan("lampiran_mime", lampiran.mimeType)
}Konfirmasi
js
const lanjut = sesi.konfirmasi({
ya: ["ya", "y", "1"],
tidak: ["tidak", "n", "0"],
pesan: "Balas YA atau TIDAK."
})
if (lanjut === null) return