Open jeromesimeon opened 4 years ago
This sounds like a regression. I'm pretty sure the parser generator used to handle optionals: https://github.com/accordproject/cicero/blob/master/packages/cicero-core/src/grammarvisitor.js#L198
This sounds like a regression. I'm pretty sure the parser generator used to handle optionals: https://github.com/accordproject/cicero/blob/master/packages/cicero-core/src/grammarvisitor.js#L198
This isn't related to parsing for optional, only the constraints for the new {{#with}}...{{/with}}
block.
The current parsing/drafting for optional values should work but will not allow for custom text for those variables.
The way I understand the issue is the ability to write something like:
{{#optional address}}
This customer lives at {{streetName}}, {{zipCode}} in {{city}}
{{else}}
This customer does not have a home address.
{{/optional}}
The current optional parsing works, but I am getting another kind of error (which may be a regression, I'm actually unsure).
For the model:
/**
* The template model
*/
concept Address {
o String zipCode
o String streetName
o String city
}
asset AcceptanceOfDeliveryClause extends AccordClause {
o Address address optional
/**
* the shipper of the goods
*/
--> Organization shipper
...
And the template:
Customer lives at:{{address}}
## Acceptance of Delivery.
{{shipper}} will be deemed to have completed its delivery obligations
if in {{receiver}}'s opinion, the {{deliverable}} satisfies the
Acceptance Criteria, and {{receiver}} notifies {{shipper}} in writing
that it is accepting the {{deliverable}}.
...
And the sample.md
text:
Customer lives at:"MainStreet" "10000" "New York"
## Acceptance of Delivery.
"Party A" will be deemed to have completed its delivery obligations
if in "Party B"'s opinion, the "Widgets" satisfies the
Acceptance Criteria, and "Party B" notifies "Party A" in writing
that it is accepting the "Widgets".
...
It parses correctly:
bash-3.2$ cicero parse --sample text/sample.md
cicero parse --sample text/sample.md
11:42:01 AM - info: Using current directory as template folder
11:42:03 AM - info:
{
"$class": "org.accordproject.acceptanceofdelivery.AcceptanceOfDeliveryClause",
"clauseId": "5beda0c6-a1cc-4f05-9cd0-529e57b9a50a",
"address": {
"$class": "org.accordproject.acceptanceofdelivery.Address",
"zipCode": "MainStreet",
"streetName": "10000",
"city": "New York"
},
"shipper": "Party A",
"receiver": "Party B",
"deliverable": "Widgets",
"businessDays": 10,
"attachment": "Attachment X"
}
But for an empty address:
Customer lives at:
## Acceptance of Delivery.
"Party A" will be deemed to have completed its delivery obligations
if in "Party B"'s opinion, the "Widgets" satisfies the
Acceptance Criteria, and "Party B" notifies "Party A" in writing
that it is accepting the "Widgets".
...
I get:
bash-3.2$ cicero parse --sample text/sample-noaddress.md
cicero parse --sample text/sample-noaddress.md
11:42:06 AM - info: Using current directory as template folder
11:42:08 AM - error: Cannot read property '$class' of null
This should be filed as a separate bug I think.
Hi Jerome, I think this bug occurs for simple types too - like String
. I have added some comments to https://github.com/accordproject/cicero/issues/521 with steps to reproduce.
In this example did you make DummyText optional?
Hi @dselman, Yes, the DummyText was optional.
o String DummyText optional
See details in https://github.com/accordproject/cicero/issues/521 See also attached, .CTA (as .ZIP archive)
From @martinhalford
Support for "optional" in Concerto
The Concerto modeling language supports
optional
properties in types, which is great, as sometimes not all parameters in an agreement are mandatory.At the moment, if a property is designated as
optional
then the Cicero parser ignore it. An error is then thrown claiming that the property is missing.It would be great if Cicero parser could support optional properties in Concerto.