Skip to content

Commit

Permalink
chore: validate that contested index is unique
Browse files Browse the repository at this point in the history
  • Loading branch information
shumkov committed Jun 11, 2024
1 parent c000f54 commit f6b572f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/rs-dpp/src/data_contract/document_type/index/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,12 @@ impl TryFrom<&[(Value, Value)]> for Index {
//todo: we should remove the name altogether
let name = name.unwrap_or_else(|| Alphanumeric.sample_string(&mut rand::thread_rng(), 24));

if contested_index.is_some() && !unique {
return Err(DataContractError::InvalidContractStructure(
"contest supported only for unique indexes".to_string(),
));
}

Ok(Index {
name,
properties: index_properties,
Expand Down

0 comments on commit f6b572f

Please sign in to comment.