tablo_core/declaration/
action_input.rs1use std::fmt;
4
5#[derive(Debug, Clone, PartialEq, Eq)]
8#[non_exhaustive]
9pub enum ActionInputFault {
10 ReservedField(String),
15 FileField(String),
19 RefusesEmpty,
23 DependentChoice(String),
27 SubmitNotCheckbox(String),
32}
33
34pub(super) fn fmt_action_input(
36 f: &mut fmt::Formatter<'_>,
37 action: &str,
38 fault: &ActionInputFault,
39) -> fmt::Result {
40 match fault {
41 ActionInputFault::ReservedField(field) => write!(
42 f,
43 "action '{action}' declares an input field named '{field}', which its POST \
44 carries itself: rename the field"
45 ),
46 ActionInputFault::FileField(field) => write!(
47 f,
48 "action '{action}' declares a file field '{field}' in its input, which an \
49 action's POST does not upload: take the file in a record form"
50 ),
51 ActionInputFault::RefusesEmpty => write!(
52 f,
53 "action '{action}' declares no input field, but its input refuses an empty \
54 submission: declare the fields it parses, or name `()`"
55 ),
56 ActionInputFault::DependentChoice(field) => write!(
57 f,
58 "action '{action}' declares a dependent choice '{field}' in its input, whose \
59 options only a resource's form refreshes: drop `depends_on`"
60 ),
61 ActionInputFault::SubmitNotCheckbox(field) => write!(
62 f,
63 "action '{action}' declares a submit checking '{field}', which renders no \
64 checkbox in its input: pick a `bool` field"
65 ),
66 }
67}