Skip to content

Commit 1baea8b

Browse files
Add support for custom assertion validation (#15)
Signed-off-by: Marcela Melara <[email protected]>
1 parent de446fb commit 1baea8b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/assertion.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ pub fn validate_assertion(assertion: &Assertion) -> Result<(), String> {
202202
Assertion::Hash(hash) => validate_hash_assertion(hash),
203203
Assertion::DoNotTrain(do_not_train) => do_not_train.verify(),
204204
Assertion::CreativeWork(creative_work) => validate_creative_work_assertion(creative_work),
205+
Assertion::CustomAssertion(custom) => validate_custom_assertion(custom),
205206
_ => Err("Unsupported assertion type".to_string()),
206207
}
207208
}
@@ -384,3 +385,17 @@ fn validate_hash_assertion(hash_assertion: &HashAssertion) -> Result<(), String>
384385

385386
Ok(())
386387
}
388+
389+
fn validate_custom_assertion(custom: &CustomAssertion) -> Result<(), String> {
390+
// Validate that the label is non-empty
391+
if custom.label.trim().is_empty() {
392+
return Err("Custom assertion must have a valid label.".to_string());
393+
}
394+
395+
// Validate that the data is non-null
396+
if custom.data.is_null() {
397+
return Err("Custom assertion must have a data field.".to_string());
398+
}
399+
400+
Ok(())
401+
}

0 commit comments

Comments
 (0)