11//! `chain` rule type impl.
22
3- use catalyst_signed_doc_spec:: { is_required:: IsRequired , metadata:: chain:: Chain } ;
3+ use anyhow:: ensure;
4+ use catalyst_signed_doc_spec:: {
5+ is_required:: IsRequired ,
6+ metadata:: { chain:: Chain , collaborators:: Collaborators } ,
7+ } ;
48
59use crate :: { CatalystSignedDocument , providers:: CatalystSignedDocumentProvider } ;
610
@@ -21,16 +25,24 @@ pub(crate) enum ChainRule {
2125
2226impl ChainRule {
2327 /// Generating `ChainRule` from specs
24- pub ( crate ) fn new ( spec : & Chain ) -> Self {
28+ pub ( crate ) fn new (
29+ spec : & Chain ,
30+ collaborators_spec : & Collaborators ,
31+ ) -> anyhow:: Result < Self > {
2532 let optional = match spec. required {
2633 IsRequired :: Yes => false ,
2734 IsRequired :: Optional => true ,
2835 IsRequired :: Excluded => {
29- return Self :: NotSpecified ;
36+ return Ok ( Self :: NotSpecified ) ;
3037 } ,
3138 } ;
3239
33- Self :: Specified { optional }
40+ ensure ! (
41+ matches!( collaborators_spec. required, IsRequired :: Excluded ) ,
42+ "Chained Documents do not support collaborators"
43+ ) ;
44+
45+ Ok ( Self :: Specified { optional } )
3446 }
3547
3648 /// Field validation rule
0 commit comments