MCPcopy Create free account
hub / github.com/dfinity/orbit / validate_uniqueness

Function validate_uniqueness

core/control-panel/impl/src/models/registry_entry.rs:242–266  ·  view source on GitHub ↗
(entry: &RegistryEntry)

Source from the content-addressed store, hash-verified

240}
241
242fn validate_uniqueness(entry: &RegistryEntry) -> ModelValidatorResult<RegistryError> {
243 match &entry.value {
244 RegistryValue::WasmModule(value) => {
245 let mut ids = REGISTRY_REPOSITORY.find_ids_where(
246 RegistryWhere::clause()
247 .and_fullname(&entry.fullname())
248 .and_version(&value.version),
249 None,
250 );
251
252 ids.retain(|id| id != &entry.id);
253
254 if !ids.is_empty() {
255 return Err(RegistryError::ValidationError {
256 info: format!(
257 "The entry is a duplicate of {}",
258 Uuid::from_bytes(ids[0]).hyphenated()
259 ),
260 });
261 }
262 }
263 }
264
265 Ok(())
266}
267
268fn validate_is_of_same_kind(entry: &RegistryEntry) -> ModelValidatorResult<RegistryError> {
269 let entries_of_kind = REGISTRY_REPOSITORY.find_ids_where(

Callers 1

validateMethod · 0.70

Calls 5

and_versionMethod · 0.80
and_fullnameMethod · 0.80
fullnameMethod · 0.80
find_ids_whereMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected