From e0b54b96f90c94026a375323969c8d166f416258 Mon Sep 17 00:00:00 2001 From: Lucas Vas Date: Mon, 5 Jan 2026 15:20:04 -0500 Subject: [PATCH] feat: prevent short-circuit evaluation for validation --- src/common/form_schema.rs | 35 +++++++++++++++++++------------- src/components/validated_form.rs | 12 +++++++---- src/pages/home_page.rs | 10 +++++++-- 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/src/common/form_schema.rs b/src/common/form_schema.rs index 0d59eaf..ed1e9fa 100644 --- a/src/common/form_schema.rs +++ b/src/common/form_schema.rs @@ -11,27 +11,27 @@ use std::collections::HashMap; pub enum InputType { /// Represents a text input. Requires a `String` key, `String` label, and `String` placeholder. /// The entered value will be returned as a single `String` value. - Text(String, String, String), + Text(String, String, String, bool), /// Represents a number input. Requires a `String` key, `String` label, and a `String` placeholder. /// The entered value will be returned as a `String`, and will be parseable into any number type /// (i.e. an `i32`, `i64`, etc) - Number(String, String, String), + Number(String, String, String, bool), /// Represents a radio input. Requires a `String` key, `String` label, and a series of `String` /// options. The selected value will be returned as a `String`. - Radio(String, String, Vec), + Radio(String, String, Vec, bool), /// Represents a checkbox input. Requires a `String` key, `String` label, and a series of `String` /// options. The selected values will be returned as a `Vec`. - Checkbox(String, String, Vec), + Checkbox(String, String, Vec, bool), /// Represents a dropdown input. Requires a `String` key, `String` label, and a series /// of `String` options. The selected value will be returned as a `String`. - Select(String, String, Vec), + Select(String, String, Vec, bool), } impl InputType { pub fn into_view(self, data_map: RwSignal>) -> impl IntoView { view! { {match self { - InputType::Text(member, label, placeholder) => + InputType::Text(member, label, placeholder, required) => EitherOf5::A(view! { }), - InputType::Number(member, label, placeholder) => + InputType::Number(member, label, placeholder, required) => EitherOf5::B(view! { }), - InputType::Checkbox(member, label, options) => + InputType::Checkbox(member, label, options, required) => EitherOf5::C(view! { }), - InputType::Radio(member, label, options) => + InputType::Radio(member, label, options, required) => EitherOf5::D(view! { }), - InputType::Select(member, label, options) => + InputType::Select(member, label, options, required) => EitherOf5::E(view! {