1. Home
  2. Fact members comparison

Fact members comparison

Print Friendly, PDF & Email

◷ Reading Time: 4 minutes

What we need Achieve

We need to compare two members of a Fact Concept. We have a Password and a ConfirmPassword as two members of a Fact Concept. Now we need to validate that the Password and ConfirmPassword are the same. If they are not same, then we shall generate a notification.

Fact Concept

  • Create a new Fact Concept for our project by right-clicking on the Project/Add New Document/Business Concept/Fact Concept.
  • Add a new Fact from the left ToolBox (we choose ‘Account’ as its Name). Then add two Members (Password and ConfirmPassword) by clicking on the Fact/Properties Window/Info/Members(Collection). The Type of both Members is ‘string’.
  • Now we add a new Assert for the Password by clicking on the Constraints (under Validation Rules) and clicking on the Assert button (bottom left of the window). For this Member we choose: ‘Not Null or Empty’.
  • For ConfirmPassword, we choose two Asserts: ‘Not Null or Empty’ and ‘Custom Expression’. Adding the ‘Not Null or Empty’ Assert is exactly the same as what we did for Password. For the ‘Custom Expression’, the settings below need to be set:
  1. Expression is: $value == $model.Password
  2. Message: Write your own message. In this example, we say: ConfirmPassword needs to equal the Password.
  3. Type: Expression
  • Now our Fact Concept has two Members as shown below (Password and ConfirmPassword):

MainFlow

  • Add a new Generic Flow by right clicking on the Project/Add New Document/Business Logic/Generic Flow.
  • Drag and drop a ‘Start’, an ‘End’ and a ‘terminate’ node to your Flow from the left ToolBox.
  • Drag and drop the Concept model from Project Explorer window to your Flow. Then connect the Start node to the Concept node and the Concept node to End. Also, connect the Concept node to your Terminate node. By having the Terminate node, we can decide under which circumstances we need to terminate the process.
  • Our MainFlow needs two Parameters:
  1. An Input Parameter (to let us feed the Flow with a JSON): we called our Input Parameter ‘Account’.
  2. A Local Parameter (it will be used when we want to terminate a Flow): we called our Local Parameter ‘InValid’.
  • To define these Parameters, click on the Properties button and on the left side you will see the ‘Variable Definition’ under ‘Parameter Declaration’.
  • The Properties below need to be set for your Concept in your MainFlow (in your MainFlow click on the Properties button and the Properties Window will appear on the left side):
  1. Copy Result To: IsValid (the Local Parameter that we created earlier)
  2. Fact Check(Collection): Click on the three dots button in front of it and add a Fact.

Feeding the MainFlow

  • We use the below JSON to feed the Flow:
{
   "Password" : "123321",
   "ConfirmPassword" : "123123"
}
  • As you will see, the Password is not equal to ConfirmPassword and we expect to receive an Error.
  • Now if you run the Flow, in the Notification Window (on the bottom of the screen), you will see an Error and its Message.
Updated on August 7, 2019

Was this article helpful?