Examples
coming soon . . .

Conditions

IF - THEN

OpenValidation defines conditions and actions of each rule with IF - THEN terms. Every rule has to have at least one keyword.
Rule
Schema
1
IF the equity of the person is LESS than 30000
2
THEN the loan may not be grantedF
Copied!
1
{
2
equity: 25000
3
}
Copied!
Rule
Schema
1
IF the company's location IS NOT in Munich
2
THEN business is getting harder
Copied!
1
{
2
location: Dortmund
3
}
Copied!

Alternative rule expressions

Alternative expressions are containing the indicator-keywords. The condition is an implicit negation.
Rule
Schema
1
the applicants age HAS NOT to be LESSER than 18
Copied!
1
{
2
age: 17
3
}
Copied!
Rule
Schema
1
the applicants age HAS to be AT LEAST 18
Copied!
1
{
2
age: 17
3
}
Copied!
Rule
Schema
1
the persons location SHOULD be germany
Copied!
1
{
2
location: iceland
3
}
Copied!

Implicit condition

You can use implicit conditions for boolean expressions .
Rule
Schema
1
the contract HAS to be signed
Copied!
1
{
2
signed: false
3
}
Copied!

Multiple conditions

AND

Rule
Schema
1
IF the age of the applicant is GREATER than 70
2
AND his residence is NOT Dortmund
3
THEN You are not allowed to be older than 70 and you must come from Dortmund
Copied!
1
{
2
residence: "Berlin",
3
age: 18
4
}
Copied!
Rule
Schema
1
the applicant's age SHOULD NOT BE LESS than 25 years old
2
AND his profession MUST be a consultant
Copied!
1
{
2
profession: "Developer",
3
age: 18
4
}
Copied!
Rule
Schema
1
the applicant's degree MUST be a Bachelor
2
AND his age MUST be at LEAST 25 years
Copied!
1
{
2
age: 24,
3
degree: "Master"
4
}
Copied!

OR

Rule
Schema
1
IF the degree of applicant IS NOT Bachelor
2
OR his professional experience is LESS than 5 years
3
THEN you must have a bachelor's degree or 5 years experience
Copied!
1
{
2
experience: 6,
3
degree: "Master"
4
}
Copied!
Rule
Schema
1
the applicant's degree MUST be a Bachelor
2
OR his professional experience MUST be at LEAST 5 years
Copied!
1
{
2
experience: 6,
3
degree: ""
4
}
Copied!

Complex condition

You have to pay attention to indents for complex conditions
Rule
Schema
1
IF the place of residence of the person IS London
2
AND the name of the person EQUALS Mycroft Holmes.
3
OR his name EQUALS Sherlock Holmes.
4
THEN the person is a genius
Copied!
1
{
2
residence: "London",
3
name: "Sherlock Holmes"
4
}
Copied!

Arithmetic examples

Rule
Schema
1
professional experience from age - 18 years MUST NOT be LESS than 10 years
Copied!
1
{
2
age: 25
3
}
Copied!
Rule
Schema
1
IF assets - liabilities NOT EQUAL 0
2
THEN the balance must always be balanced
Copied!
1
{
2
assets: 1,
3
liabilties: 2
4
}
Copied!
Rule
Schema
1
IF equity / total assets NOT SAME equity ratio
2
THEN the balance sheet contains errors
Copied!
1
{
2
assets: 100,
3
equity: 25
4
}
Copied!
String operations are not possible at the moment

Variables

Numeric values
Variable definition
1
42
2
AS answer to everything
Copied!
Strings
Variable definition
1
Validaria
2
AS helpful
Copied!
Boolean expressions
Variable definition
1
the age of the applicant is LESS than 18 years old
2
AS underage
Copied!
Arithmetic expressions
Variable definition
1
age - 18
2
AS professional experience
Copied!

Comments

comment
1
COMMENT This is a commentary
Copied!
comment
1
COMMENT Multi-line comments
2
are also possible
Copied!

OpenAPI

OpenVALIDATION ships a OpenAPI plugin, which defines the validationrules for the serviceoperations.
oapi.spec.yaml
Download
1
openapi: "3.0.0"
2
info:
3
version: 1.0.0
4
title: openVALIDATION
5
description: openVALIDATION Beispiele.
6
paths:
7
/:
8
post:
9
requestBody:
10
content:
11
application/json:
12
schema:
13
$ref: '#/components/schemas/person'
14
x-ov-rules:
15
culture: en
16
rule: |
17
18
COMMENT This is a comment, Miss Honey
19
20
IF the persons equity is LESS THAN 30000
21
THEN a loan could not be granted
22
23
24
responses:
25
'200':
26
description: success
27
components:
28
schemas:
29
person:
30
type: object
31
properties:
32
equity:
33
type: integer
Copied!
oapi.spec.yaml
764B
Code
oapi.spec.yaml