mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-22 21:04:27 +01:00
Add function to validate settings in Meilisearch, to be used in the routes
This commit is contained in:
parent
9123370e90
commit
ec9649c922
@ -318,6 +318,21 @@ impl Settings<Unchecked> {
|
|||||||
_kind: PhantomData,
|
_kind: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn validate(self) -> Result<Self, milli::Error> {
|
||||||
|
self.validate_embedding_settings()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn validate_embedding_settings(mut self) -> Result<Self, milli::Error> {
|
||||||
|
let Setting::Set(mut configs) = self.embedders else { return Ok(self) };
|
||||||
|
for (name, config) in configs.iter_mut() {
|
||||||
|
let config_to_check = std::mem::take(config);
|
||||||
|
let checked_config = milli::update::validate_embedding_settings(config_to_check, name)?;
|
||||||
|
*config = checked_config
|
||||||
|
}
|
||||||
|
self.embedders = Setting::Set(configs);
|
||||||
|
Ok(self)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
Loading…
Reference in New Issue
Block a user