Validations
Overview
You can create validations for your data, which will allow for any set of source data to undergo simple validation or combination checking. Such user-defined validations are general, i.e. they refer to all Fynapse modules. You can define validations for Defined Entities and Protected Entities.
The subject of a validation can be:
- data within the given Entity
- data appended to the Entity by references in the process of enrichment
This means you can create validations verifying the reference criteria established for an Entity. Such validation references are sets of rules that determine which data from which Entity is used to enrich the base Entity is validated within a validation. This will create more complex validation rules for your data.
As a result, you can validate whether the relations you created within your data structure meets the defined criteria.
The aim of validations is to pre-empt failures that could occur later within the system, e.g.:
- catch the data validation errors or combination failures on the input source record
- re-check against the current set of rules when feeding external systems
Types of validations
Simple
Simple validations are typically applied to verify inbound data. They allow you to verify if the attribute value entered in or imported to various modules of Fynapse is valid. Values are valid according to business requirements for Aptitude and downstream system processing.
Conditional
Conditional validations allow you to verify if the data in a given field is valid in combination with data in other fields. An example of this would be to check that a specific Cost Center/Entity combination is valid for a specific Business Event. These types of validations are used to verify combinations of values after Fynapse has changed a value, for example a GL Account was derived or a legal entity was changed in an intercompany process.
Validation Syntax
Validations are defined in the Configuration Data JSON file. The input definition has to be built in accordance with the structure provided below.
Sample Structure of an Entity with a Reference and a Validation
Sample JSON structure
This is a sample structure of an Entity, Legal Entity, with a defined reference to an Organization Unit Entity and a defined mandatory type validation checking this reference:
Simple Validations
All types of simple validations have the following common properties:
where:
- name - the unique name of the validation
- type - defines the type of the validation; there are three types:
- MANDATORY - the attribute or reference for which this validation was defined cannot be empty
- ENUM - the attribute or reference for which this validation was defined has to have a value from the list provided in the ‘values’ property
- LOOKUP - a check is made if the referenced Entity exists
- attributeName - name of the attribute or reference that is the subject of the validation
- for attributes - nameOfTheAttribute
- for references - referenceName.nameOfTheReference
Mandatory Validations
Mandatory validations have simple structure:
Mandatory validation for an attribute of a referenced Entity:
Enum Validations
Enum validations have an additional ‘values’ property which lists the allowed values:
where:
- values - list of allowed values, which you have to define
Enum validation for checking the values of an attribute in a referenced Entity:
where:
- referenceName.nameOfTheAttributeInReferencedEntity
- referenceName - name of the reference which is the subject of the validation
- nameOfTheAttributeInReferencedEntity - name of the attribute in the referenced Entity
Lookup Validations
Lookup type validations have a slightly different syntax to other simple validations.
There are two types of lookup validations:
- Mapping an attribute from Business Event to an attribute from Organization Unit Entity:
where:
- name - the unique name of the validation
- type - the type of validation, here: LOOKUP
- entity - Entity we are referring to
- namespace - Entities are grouped into logical sets called namespaces. This ensures easy identification, as Entities within each namespace have to have unique names.
Currently, the value for this property should be defined as ‘fynapse’. - reference - definition of the conditions for reference
- type
- Attribute - an attribute from Business Event to an attribute from Entity Organization Unit
- attributeName - name of the attribute from referring Business Event
- referencedAttribute - name of the attribute from referred Entity Organization Unit
- type
2. Mapping an attribute from Business Event to a value of an attribute from Organization Unit Entity:
where:
- name - the unique name of the validation
- type - the type of validation, here: LOOKUP
- entity - the Entity we are referring to
- namespace - Entities are grouped into logical sets called namespaces. This ensures easy identification, as Entities within each namespace have to have unique names.
Currently, the value for this property should be defined as ‘fynapse’. - reference - definition of the conditions for reference
- type
- Const - mapping from Entity A to a determined value of an attribute in FDS Entity Organization Unit
- value - allowed value of the referenced attribute
- referencedAttribute - referenced attribute from referred FDS Entity Organization Unit
- type
Lookup validation for an Entity with a defined reference and with validation from this referred Entity to a different Entity
In this example, the basic Entity is a Business Event. This Business Event Entity has a defined reference to the Organization Unit Entity. You can create a validation from this referred Organization Unit Entity to another Entity, e.g. Account, which is not directly referred to in the Business Event.
Conditional Validations
Conditional validations are created by adding the ‘when’ clause to a simple validation. The initial parameters are the same as for simple validations.
If you do not add the ‘when’ clause, the system will trigger the validation as a simple validation.
where:
- when - opens the section which defines the conditions for when the validation will be applicable
- logicalOperator - determines whether this is an “and“ or “or” combination validation, the allowed values are:
- AND - all conditions have to be met
- OR - at least one of the conditions has to be met
- operands - the properties which constitute the definition of the condition
- condition - trigger for validation
- inList - list of allowed values that trigger the condition
- notNull - cannot be empty
- attributeName - is the value of this attribute in the allowed values
- values - allowed values
- condition - trigger for validation
References
You can create more complex validations by defining references for your Entities.
Reference Syntax
where:
- name - name of the reference
- label - label of the reference
- entity - Entity being referenced
- namespace - Entities are grouped into logical sets called namespaces. This ensures easy identification, as Entities within each namespace have to have unique names.
Currently, the value for this property should be defined as ‘fynapse’. - definition - definition of the reference
- typeName - type of the reference
- Attribute - reference to an attribute from Legal Entity to an attribute from the Organization Unit Entity
- Const - reference from Entity A to a determined value of an attribute in the Organization Unit Entity
- referencedAttribute - the attribute from the referenced Entity
- attributeName - the name of the attribute in the referring Entity for Attribute type references
- value - the value of the attribute in the referenced Entity for Const type references
- typeName - type of the reference
Primary Keys
When creating a reference you have to cover Primary Keys. A Primary Key is a unique attribute or set of attributes which identify an Entity in the system. What this means is, if you define a Primary Key consisting of one attribute then you have to create a reference to this attribute when referring to this Entity. You can create references to other attributes as well, but Primary Key attributes are mandatory for a reference. Let’s look at the example above. We are creating a reference to the Organization Unit Entity which has one Primary Key attribute - Organization Unit Identifier. Additionally, we are also creating a reference to the Organization Unit Identifier Type attribute, which is not part of the Primary Key, but we still want to reference it.
If you are defining a reference for the Business Event Entity, you can add an optional description:
Validation Errors
If a validation fails, one of the following errors will be thrown:
Examples
This section shows examples of simple and complex validations.
Examples of simple validations
Mandatory Attribute
In this example, we are going to define a validation that checks if the GL Account Attribute is provided.
The definition for such a validation would be:
With this validation, the system would behave as follows:
GIVEN the below validation was configured in Fynapse
AND a Business Event was ingested into Fynapse
WHEN Accounting Engine tries to assign ‘GL Account’ value to the imported Business Event
AND it was impossible to assign ‘GL Account’ value to this Business Event based on the rules set up in the Accounting Rules Navigator
AND no ‘GL Account’ value was assigned to the Business Event
THEN the Validation Service returns the following error:
‘The “GL Account not empty” validation rule failed. The “GL Account” attribute or reference is empty.’
AND the transaction isn’t posted
Enum Validation
In this example, we are going to define a validation that checks if the provided values for GL Account are consistent with the user-defined list of allowed values.
The definition for such a validation would be:
With this validation, the system would behave as follows:
GIVEN the below validation was configured in Fynapse
AND a Business Event was ingested into Fynapse
WHEN Accounting Engine assigns ‘GL Account’ value to the imported Business Event
AND a ‘GL Account’ value which was assigned to this Business Event based on the rules set up in Accounting Rules Navigator was ‘5000’
THEN Validation Service returns the following error:
‘The “GL Account allowed values” validation rule failed. The “5000” value is not allowed for the “GL Account” attribute. The allowed values are: “1000, 2100, 3200, 4000, 4800”.’
AND the transaction isn’t posted
Lookup Validation
In this example, we are going to define a validation that verifies the reference between the Currency Code attribute and Currency Identifier attribute.
The definition for such a validation would be:
With this validation, the system would behave as follows:
GIVEN the below validation was configured in Fynapse
with the following validation conditions
AND a Business Event Definition looks like the following:
AND data which exists in the ‘Currency’ table is like below:
AND a Business Event was ingested into Fynapse
AND a currencyCode value in the imported Business Event was ‘CHF’
WHEN Validation Service validates this Business Event
THEN the following error is returned:
‘The “Currency code validation” rule failed. Lookup to Entity “Currency” in the “fynapse” namespace failed. The following data was not found:
- currencyCode = “CHF”’
AND the transaction isn’t posted
Mandatory Reference
In this example, we are going to define a validation that verifies if the mandatory Legal Entity attribute exists in the referenced Organization Unit.
The definition for such a validation would be:
With this validation, the system would behave as follows:
GIVEN below Business Event reference was configured in Fynapse
with below mandatory attributes (reference conditions)
AND a Business Event Definition contains a ‘Cost Centre’ field
AND a Business Event Definition does NOT contain a ‘Legal Entity’ field
AND it looks like the following:
AND a following validation was configured in Fynapse
AND the only rows in ‘Organisation Unit’ table are like the following:
AND a Business Event was ingested into Fynapse
AND a Cost Centre value in the imported Business Event is ‘200’
WHEN Data Structure calls the Enrichment Service from Accounting Engine
AND a ‘legalEntity’ reference can’t be found (no row is found in the ‘Organisation Unit’ table for the imported Business Event with ‘200’ Cost Centre value)
THEN the Validation Service returns the following error:
‘The “Mandatory legal Entity” validation rule failed. The reference “legalEntity” was not found. The “empty” value is not allowed for the “Organisation Unit Identifier” attribute.’
AND the transaction isn’t posted
Examples of conditional validations
Mandatory Attribute with IF Condition
In this example, we are going to define a validation that checks if the Cost Centre Attribute is not empty for a GL Account Attribute with the value ‘4000’.
The definition for such a validation would be:
With this validation, the system would behave as follows:
GIVEN the below validation was configured in Fynapse
AND a Business Event was ingested into Fynapse
AND a ‘Cost Centre’ value is not provided in the imported Business Event
AND no Business Event references were defined in Fynapse
WHEN Accounting Engine processes this Business Event
AND a ‘GL Account’ value ‘4000’ was assigned to this Business Event
THEN Validation Service returns the following error:
‘The “Cost Centre not empty for GL Account 4000” validation rule failed. The “Cost Centre” attribute or reference is empty.
Cause for conditional validation:
- The “GL Account” attribute has a “4000” value.’
AND the transaction isn’t posted
Enum Validation with IF Condition
In this example, we are going to define a validation that checks if the value in GL Account field is ‘5100’ and the value for Company field is ‘AS’.
IF GL Account = ‘5100’ THEN Company = ‘AS’
The definition for such a validation would be:
With this validation, the system would behave as follows:
GIVEN below validation was configured in Fynapse
AND a Business Event was ingested into Fynapse
AND a Company value provided in the imported Business Event is ‘50’
AND no Company override was configured on the Journal mapping screen
WHEN Accounting Engine processes this Business Event
AND a GL Account value ‘5100’ was assigned to this Business Event
THEN Validation Service returns the following error:
‘The “GL Account & Company matrix” validation rule failed. The “50” value is not allowed for the “Company” attribute. The allowed values are: “AS”.
Cause for conditional validation:
- The “GL Account” attribute has “5100” value.’
AND the transaction isn’t posted
Lookup Validation with IF Condition
In this example, we are going to define a validation that checks the company in the Organisation Unit Entity if the value in the Source System field = ‘BILLING1’.
The definition for such a validation would be:
With this validation, the system would behave as follows:
GIVEN the following validation was configured in Fynapse
with the following validation conditions
AND a Business Event Definition contains ‘company’ and ‘sourceSystem’ fields
AND it looks like the following:
AND data which exists in the ‘Organisation Unit’ table looks like below:
AND a Business Event was ingested into Fynapse
AND a ‘company’ value in the imported Business Event was ‘67’
AND a sourceSystem value was ‘BILLING1’
WHEN Validation Service validates this Business Event
THEN the following error is returned:
‘The “Company validation for BILLING1 sourceSystem” rule failed. Lookup to Entity “Organisation Unit” in the “fynapse” namespace failed. The following data was not found:
- company = “67”
Cause for conditional validation:
- The “sourceSystem” attribute has “BILLING1” value.’
AND the transaction is NOT posted