Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Questions about rules #160

Open
bronnikova18 opened this issue Apr 11, 2022 · 5 comments
Open

Questions about rules #160

bronnikova18 opened this issue Apr 11, 2022 · 5 comments
Labels

Comments

@bronnikova18
Copy link

Please provide sample code to define the following basic rules in Orchestra:

  1. field is required and it's value != some string value
  2. field is optional, but if field exists, it's value <= some float value
  3. if field1 == 'some value' field2 and field3 are forbidden
    Thanks!
@donmendelson
Copy link
Member

I'm not sure of the business use case, so my examples may not be realistic, but I'll try to show the format.

  1. You could encode this as presence is required except that a certain value is forbidden.
<fixr:fieldRef id="145" presence="required">
	<fixr:rule name="exception" presence="forbidden">
		<fixr:when>DeliverToLocationID == "BadLocation"</fixr:when>
	</fixr:rule>
</fixr:fieldRef>
  1. Again, use a rule that sets it to forbidden in a certain exception case. Uses existence operator of Score DSL. Note that "le" operator avoids having to use an escape sequence for < in XML.
<fixr:fieldRef id="2646">
	<fixr:rule name="exception" presence="forbidden">
		<fixr:when>exists CommissionRate and CommissionRage le 0.10 </fixr:when>
	</fixr:rule>
</fixr:fieldRef>
  1. Write the rules for field2 and field3.
<fixr:fieldRef id="9999">
	<fixr:rule name="Field2Exception" presence="forbidden">
		<fixr:when>field1 == "some value"</fixr:when>
	</fixr:rule>
</fixr:fieldRef>

@JoanPuig
Copy link

How would you create a rule that enforces a given number of occurrences in a repeating group? Example, in a swap trade I want to make sure that there is exactly one party of type clearing house. I think I can filter them like this: Parties[PartyRole==4] but is there a count or length operator/function?

@donmendelson
Copy link
Member

The overall size of a repeating group may be limited with group attributes; see Repeating group

Limits on the size of a repeating group may optionally be specified with implMinOccurs and implMaxOccurs attributes. If those attributes are not present, then the repeating has unbound size.

There currently is no count operator. However, we are gathering proposed enhancements for Orchestra v1.1, so feel free to propose a syntax for it.

@bronnikova18
Copy link
Author

Thank you! Examples are very helpful.

Could you please provide one more example:

  • field2 is required and field2='somevalue1' if field1=''anothervalue1' and field2='somevalue2' if field1='anothervalue2'

@donmendelson
Copy link
Member

I propose to add these examples to v1.1 documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants