(entry: &RegistryEntry)
| 240 | } |
| 241 | |
| 242 | fn 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 | |
| 268 | fn validate_is_of_same_kind(entry: &RegistryEntry) -> ModelValidatorResult<RegistryError> { |
| 269 | let entries_of_kind = REGISTRY_REPOSITORY.find_ids_where( |
no test coverage detected