From 2366d609d4838263a5dae66207e52b7b713e9ea4 Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Fri, 19 Jan 2024 22:23:13 -0800 Subject: [PATCH] add checked to form --- packages/html/src/events/form.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/html/src/events/form.rs b/packages/html/src/events/form.rs index 75cc51978..442b63aa5 100644 --- a/packages/html/src/events/form.rs +++ b/packages/html/src/events/form.rs @@ -90,6 +90,14 @@ impl FormData { self.inner.value() } + /// Try to parse the value as a boolean + /// + /// Returns false if the value is not a boolean, or if it is false! + /// Does not verify anything about the event itself, use with caution + pub fn checked(&self) -> bool { + self.value().parse().unwrap_or(false) + } + /// Get the values of the form event pub fn values(&self) -> HashMap { self.inner.values()