UPDATE: Adds name validation and exposes it in wasm

We do a trick I am not proud of. Because all of our errors are Strings,
we don't have a way to separate a name error from an index error,
for instance. What I do in prepend the error with a string that indicates
where it comes from.
This commit is contained in:
Nicolás Hatcher
2025-11-17 19:57:18 +01:00
committed by Nicolás Hatcher Andrés
parent 3db094c956
commit 1391f196b5
7 changed files with 108 additions and 49 deletions

View File

@@ -2001,7 +2001,10 @@ impl UserModel {
new_scope: Option<u32>,
new_formula: &str,
) -> Result<(), String> {
let old_formula = self.model.get_defined_name_formula(name, scope)?;
let old_formula = self
.model
.get_defined_name_formula(name, scope)
.map_err(|_| "General: Failed to get old name")?;
let diff_list = vec![Diff::UpdateDefinedName {
name: name.to_string(),
scope,
@@ -2017,6 +2020,16 @@ impl UserModel {
Ok(())
}
/// validates a new defined name
pub fn is_valid_defined_name(
&self,
name: &str,
scope: Option<u32>,
formula: &str,
) -> Result<Option<u32>, String> {
self.model.is_valid_defined_name(name, scope, formula)
}
// **** Private methods ****** //
pub(crate) fn push_diff_list(&mut self, diff_list: DiffList) {