Domain-specific operators
in process...
The aim of openVALIDATION's grammar is to be as natural as possible. To get even closer to this goal, it is possible to declare domain-specific or semantic operators in the rules.
An example
Schema:
Rule:
The rule sounds quite natural, but not quite. The rule could sound much more natural if it were expressed as follows:
That sounds a lot more natural. The problem is that even if openVALIDATION would provide an alias for the operator <
called YOUNGER
, at the end openVALIDATION does not know which attribute of the schema should be used for the comparison operation. We have to tell openVALIDATION that somehow. We do this by defining a user-defined, domain-specific operator:
We can create a domain-specific comparison operator using a new global element as operator. We can then use this in our rules. In our example, we have created a new comparison operator called younger
. The operator itself consists of a concrete comparison operator, namely less
and the attribute age of the schema. The keyword and in between is optional.
Domain-specific or semantic operators can be created in advance, e.g. together with the variables, and then serve as a semantic basis for the actual validation rules.
Last updated