Automatically Validate Business Rules Against a Library of Messages
Business Rules Against
a Library of Messages
In most integrations, validating a library of messages against the schema is the first step - you will also need to validate against a set of business rules.
You may have a series of processes that generate LIXI2 messages for submitting to an API or you may host an API that consumes LIXI2 messages. The capability to automatically validate a set of messages with some business logic is likely needed.
I already showed (here) how to automatically validate a library of LIXI2 messages using our standards directly cloned from LIXILab.
In this blog post, I build upon the previous blog to include LIXI business rules validation of the LIXI2 messages. We fetch the latest standards, fetch a library of test messages, fetch some business rules (from LIXI Schematron Repository), and validate all the messages against both the latest standards and business rules.
Step 1. Create Folder and Clone Projects
Start this process by creating a folder called 'lixi-rules-validation-demo' - I've created this under the 'C:\temp\' directory.
Then, just like the previous tutorial, proceed to use the command or bash window to use the git clone command to clone both the LIXI2 schemas, LIXI2 samples and LIXI2 Schematron projects locally from LIXILab. If this is your first time running this command, you will be asked for your credentials for LIXILab. Notice that I have changed git clone command for schematron rules project slightly to clone into a 'rules' folder.
Step 2. Copy the Python Code into a New File
In the new folder create an empty file called validate_rules_standalone_script.py and copy the code from the block at the bottom of this page into the file and save it.
After completing this, you will have two sub-directories and a single python script.
└── lixi-rules-validation-demo ├── rules ├── samples ├── schemas └── validate_rules_standalone_script.py
Step 3. Run the Python Script
Depending on your Python installation, you can now run the script - you could use an IDE such as vsCode or execute the script from a command or bash session. For example, you can run it at the Windows CMD prompt as follows.
Step 4. What Next? Extend the rules of course!
This is just a demonstration of how you might plug business rules validation with the help of LIXI2 on your journey to automate your software delivery lifecycle.
The same rules can be extended to cater your organization's unique business rules. Or you can help expand the general message business rules with your contribution at Schematron Library of Business Rules project in LIXILab.
Python Code to Save in 'validate_rules_standalone_script.py'
Shane Rigby, LIXI Limited CEO
First Published: February 4, 2021