You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Docstrings generation was requested by @Athemis.
* #4 (comment)
The following files were modified:
* `src/logic/eln.rs`
* `src/models/extra_fields.rs`
* `src/mvu/mod.rs`
* `src/ui/components/extra_fields.rs`
* `src/ui/mod.rs`
/// let b = ExtraField { position: None, ..a.clone() };
116
+
/// assert_eq!(a.cmp_key(), (1, "A"));
117
+
/// assert_eq!(b.cmp_key().0, std::i32::MAX);
118
+
/// ```
75
119
pubfncmp_key(&self) -> (i32,&str){
76
120
(self.position.unwrap_or(i32::MAX),&self.label)
77
121
}
78
122
}
79
123
80
-
/// Pure validation of a single extra field. Returns `Some(reason_code)` when invalid.
124
+
/// Validate a single extra field and return a short reason code when it is invalid.
125
+
///
126
+
/// This performs minimal, pure validation based on the field's kind and required flag:
127
+
/// - If the field is required and empty, returns `Some("required")`.
128
+
/// - For `Url`: empty values are allowed; otherwise the value must parse as an `http` or `https` URL with a host, otherwise returns `Some("invalid_url")`.
129
+
/// - For `Number`: empty values are allowed; otherwise the value must parse as a floating-point number, otherwise returns `Some("invalid_number")`.
130
+
/// - For `Items`, `Experiments`, `Users`: empty values are allowed; otherwise the value must parse as a 64-bit integer, otherwise returns `Some("invalid_integer")`.
131
+
/// - For all other kinds, no validation error is produced.
132
+
///
133
+
/// # Returns
134
+
///
135
+
/// `Some(reason)` when validation fails, where `reason` is one of:
136
+
/// - `"required"`
137
+
/// - `"invalid_url"`
138
+
/// - `"invalid_number"`
139
+
/// - `"invalid_integer"`
140
+
///
141
+
/// Returns `None` when the field is valid.
142
+
///
143
+
/// # Examples
144
+
///
145
+
/// ```
146
+
/// # use crate::models::extra_fields::{ExtraField, ExtraFieldKind, validate_field};
/// Validate model state and build the payload required to save an archive.
307
+
/// Validate the current application model and construct a `SavePayload` for writing an archive.
308
+
///
309
+
/// Performs these checks and conversions:
310
+
/// - Ensures the entry title is non-empty.
311
+
/// - Trims body text and collects normalized keywords.
312
+
/// - Converts the datetime picker value to an `OffsetDateTime`.
313
+
/// - Converts attachments to domain metadata and enforces unique sanitized filenames.
314
+
/// - Validates each extra field and returns a field-specific user-facing error message on failure.
315
+
///
316
+
/// # Returns
317
+
///
318
+
/// `Ok(SavePayload)` containing the assembled data required to save an archive on success, `Err(String)` with a user-facing error message describing the first validation failure otherwise.
319
+
///
320
+
/// # Examples
321
+
///
322
+
/// ```rust,no_run
323
+
/// // Given a populated `model: AppModel` and an output path:
324
+
/// let payload = validate_for_save(&model, std::path::PathBuf::from("entry.eln"));
325
+
/// match payload {
326
+
/// Ok(p) => println!("Ready to save to {:?}", p.output),
0 commit comments