Ready to go in 3 min.


You need Java version 8 or higher. Here you can download the corresponding JRE 1.8.

1. Installation

You need openvalidation.jar to generate code. openvalidation.jar is a simple Java command line interface. You can download the openvalidation.jar here:
Best you create a new directory under your personal Temp folder and download the openvalidation.jar into this folder:
cd %temp%
mkdir openvalidation
cd openvalidation
Best you create a new directory under your personal Temp folder and download the openvalidation.jar into this folder:
cd /tmp/
mkdir openvalidation
cd openvalidation

2. Create a rule

Ok, now you are ready to start and can program your first validation rule in openVALIDATION. Create a file called rules.ov and add the following content:
IF the message IS Hello
This rule is formatted so that it best illustrates the keywords and syntax of the openVALIDATION language. You could also just write If the message is Hello then hello openVALIDATION! and it would work just the same.
In addition to the actual rule, you also need a schema. The schema defines the data structure of the data set to be validated. You can use a simple JSON object from which a JSON schema is automatically derived. Our schema consists only of a text field called "Message".
Message : Text
Message : "Text"

3. Generate code

Since our validation rule and the corresponding schema are already fixed, we can now generate the corresponding code.
java -jar openvalidation.jar /
-r rules.ov /
-s "{Message : \"Text\"}" /
-l javascript /
-o myRules.js /
-c en /
The Rule parameter is used to pass the actual validation rule either directly or as a file reference. In our case, we pass the file rules.ov
The schema specifies the data structure for openVALIDATION.
The programming language to be translated
The culture code of natural language (de for German/ en for English)
Output Parameter defines the code file. Alternatively you can specify a directory where the code files will be stored after the generation process. Without specifying the output parameter, the generated code will only be output in the console
This parameter (--single-file) ensures that the generated code is generated in a file. Normally there are two files: the base framework and the implementation of the rules
Congratulations! You have just created your first validation rule in JavaScript. This can be found in the file myRules.js. This is the result:
"Hello openVALIDATION!",
function(model) { return huml.EQUALS(model.Message, "Hello");},

4. Rules integration

Now we'd like to see if our rule works. We create a file called test.html and add the following code:
<input id="message" />
<div id="error"></div>
<script src="myRules.js"></script>
<script type="text/javascript">
window.addEventListener('load', (event) => {
var validator = new HUMLValidator();
document.getElementById('message').onkeyup = function(e){
var result = validator.validate({});
if (result.hasErrors)
document.getElementById('error').textContent = result.errors[0].error;
document.getElementById('error').textContent = "";
We call the test.html in the browser and type "Hello" into the input field:
As expected, when entering the value "Hello", our error message appears.

5. No-Code Development

You can now extend the rules by filling the file rules.ov with additional rules and then doing the generation process again using openVALIDATION CLI. Just follow steps 2 to 4.
The nice thing about it is that the file rules.ov can now be edited by a domain expert without having to be familiar with the technology! As soon as he has changed the rules, openVALIDATION can automatically generate program code from them. This is what we call No-Code Development.
If you would like to try out another detailed implementation example, then have a look at the Integration section.
Last modified 4yr ago