You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"'type' and 'multiple' fields could not been specified when 'required' is 'excluded' for 'template' metadata definition"
41
+
);
38
42
returnOk(Self::NotSpecified);
39
43
},
40
44
};
41
45
42
-
anyhow::ensure!(spec.doc_type.len() == 1,"'type' field should exists and has only one entry for the required 'reply' metadata definition");
43
46
anyhow::ensure!(
44
47
spec.multiple.is_some_and(|v| !v),
45
48
"'multiple' field should be only set to false for the required 'reply' metadata definition"
46
49
);
47
50
48
-
let doc_name = spec.doc_type.first().ok_or(anyhow::anyhow!("'type' field should exists and has only one entry for the required 'reply' metadata definition"))?;
49
-
let docs_spec = docs.get(doc_name).ok_or(anyhow::anyhow!(
51
+
let doc_name = &<&[DocumentName;1]>::try_from(spec.doc_type.as_slice()).map_err(|_| anyhow::anyhow!("'type' field should exists and has only one entry for the required 'reply' metadata definition"))?[0];
52
+
let docs_spec = docs.get(&doc_name).ok_or(anyhow::anyhow!(
50
53
"cannot find a document definition {doc_name}"
51
54
))?;
52
55
let allowed_type = docs_spec.doc_type.as_str().parse()?;
"'type' and 'multiple' fields could not been specified when 'required' is 'excluded' for 'template' metadata definition"
40
+
);
41
41
returnOk(Self::NotSpecified);
42
42
}
43
43
44
44
anyhow::ensure!(
45
45
spec.multiple.is_some_and(|v| !v),
46
-
"'multiple' must be `false` for 'template' metadata definition"
46
+
"'multiple' field should be only set to false for the required 'reply' metadata definition"
47
47
);
48
48
anyhow::ensure!(
49
49
spec.required != IsRequired::Optional,
50
-
"'required' field cannot been 'optional' for 'template' metadata definition"
50
+
"'required' field cannot been 'optional' for 'template' metadata definition"
51
51
);
52
52
53
-
let doc_name = spec.doc_type.as_ref().ok_or(anyhow::anyhow!(
54
-
"'type' field should exists for the required 'template' metadata definition"
55
-
))?;
56
-
let docs_spec = docs.get(doc_name).ok_or(anyhow::anyhow!(
53
+
let doc_name = &<&[DocumentName;1]>::try_from(spec.doc_type.as_slice()).map_err(|_| anyhow::anyhow!("'type' field should exists and has only one entry for the required 'reply' metadata definition"))?[0];
54
+
let docs_spec = docs.get(&doc_name).ok_or(anyhow::anyhow!(
57
55
"cannot find a document definition {doc_name}"
58
56
))?;
59
57
let allowed_type = docs_spec.doc_type.as_str().parse()?;
0 commit comments