From 6b241feda5bb4ba9a355b56cb7f2c5b713ec9bd1 Mon Sep 17 00:00:00 2001 From: Daniil Fajnberg Date: Tue, 26 Apr 2022 21:55:56 +0200 Subject: [PATCH] form field `clean` now force-stringifies value --- src/yamlhttpforms/form.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/yamlhttpforms/form.py b/src/yamlhttpforms/form.py index 9f233aa..85b9d28 100644 --- a/src/yamlhttpforms/form.py +++ b/src/yamlhttpforms/form.py @@ -61,7 +61,8 @@ class FormField: def valid_option(self, option: str) -> bool: return self.options is None or option in self.options.keys() or option in self.options.values() - def clean(self, value: str) -> str: + def clean(self, value: Any) -> str: + value = str(value) if self.options is None or value in self.options.keys(): return value # Try to find an unambiguous match in the visible option texts: