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
Rule
IF the equity of the person is LESS than 30000
THEN the loan may not be grantedF
Schema
{
equity: 25000
}
Rule
Schema
Rule
IF the company's location IS NOT in Munich
THEN business is getting harder
Schema
{
location: Dortmund
}

Alternative rule expressions

Alternative expressions are containing the indicator-keywords. The condition is an implicit negation.

Rule
Schema
Rule
the applicants age HAS NOT to be LESSER than 18
Schema
{
age: 17
}
Rule
Schema
Rule
the applicants age HAS to be AT LEAST 18
Schema
{
age: 17
}
Rule
Schema
Rule
the persons location SHOULD be germany
Schema
{
location: iceland
}

Implicit condition

You can use implicit conditions for boolean expressions .

Rule
Schema
Rule
the contract HAS to be signed
Schema
{
signed: false
}

Multiple conditions

AND

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

OR

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

Complex condition

You have to pay attention to indents for complex conditions

Rule
Schema
Rule
IF the place of residence of the person IS London
AND the name of the person EQUALS Mycroft Holmes.
OR his name EQUALS Sherlock Holmes.
THEN the person is a genius
Schema
{
residence: "London",
name: "Sherlock Holmes"
}

Arithmetic examples

Rule
Schema
Rule
professional experience from age - 18 years MUST NOT be LESS than 10 years
Schema
{
age: 25
}
Rule
Schema
Rule
IF assets - liabilities NOT EQUAL 0
THEN the balance must always be balanced
Schema
{
assets: 1,
liabilties: 2
}
Rule
Schema
Rule
IF equity / total assets NOT SAME equity ratio
THEN the balance sheet contains errors
Schema
{
assets: 100,
equity: 25
}

String operations are not possible at the moment

Variables

Numeric values

Variable definition
Variable definition
42
AS answer to everything

Strings

Variable definition
Variable definition
Validaria
AS helpful

Boolean expressions

Variable definition
Variable definition
the age of the applicant is LESS than 18 years old
AS underage

Arithmetic expressions

Variable definition
Variable definition
age - 18
AS professional experience

Comments

comment
comment
COMMENT This is a commentary
comment
comment
COMMENT Multi-line comments
are also possible

OpenAPI

OpenVALIDATION ships a OpenAPI plugin, which defines the validationrules for the serviceoperations.

oapi.spec.yaml
Download
oapi.spec.yaml
openapi: "3.0.0"
info:
version: 1.0.0
title: openVALIDATION
description: openVALIDATION Beispiele.
paths:
/:
post:
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/person'
x-ov-rules:
culture: en
rule: |
COMMENT This is a comment, Miss Honey
IF the persons equity is LESS THAN 30000
THEN a loan could not be granted
responses:
'200':
description: success
components:
schemas:
person:
type: object
properties:
equity:
type: integer