Servigistics InService Customization > Customizing CSV Validations > Configuring Custom Validations for CSV Files
  
Configuring Custom Validations for CSV Files
Servigistics InService enables you to add custom validations for comma-separated value (CSV) files using a copy of the configuration file customizedContext_XX.conf.xml located in the directory <INS_HOME>/InS_SW/Config/System/Config. In the customizedContext_XX.conf.xml file name, XX represents the default numeric value for the file.
It is not recommended to edit the default configuration file. Instead, you can create a copy of the default configuration file and add custom validations to the copied version of the file. The copied configuration file name must have a numeric value less than the default numeric value for the file. For example, if the default file name is customizedContext_3.conf.xml, then you can copy and save this file as customizedContext_2.conf.xml. You can then use the customizedContext_2.conf.xml file to add custom validations. Hereafter, the copied version of the default configuration file is referenced as customizedContext_YY.conf.xml.
The custom validation must extend a default validation. For a list of default validations for CSV files, see Default Validations for CSV Files.
You define a component for each validation in the customizedContext_YY.conf.xml file and include the validation entry under the CSVFileValidationScanner component of the customizedContext_YY.conf.xml file. For more information, about adding a custom validation, see Adding a Custom Validation for CSV Files.
Defining Validations
A validation component in the customizedContext_YY.conf.xml file includes the following details:
Element
Description
Component
Specifies the name of the validation component.
Creation
Specifies the method used for creating the component. The Type attribute for this element is always JavaObject.
Class
Specifies the Java class of the validation component. A Java class is a custom Java file that extends an existing default validation for CSV files.
Config
Specifies configuration details, such as the validation information.
Validation
Specifies the following validation attributes:
code: The error code of the validation.
description: A description for the validation.
resolution: The resolution for the validation.
* 
These attributes are displayed for a validation in the validations result file after you run the Validate CSV Data task from the Task Manager.
The following validation component shows the attributes defined for the component:
<Component Name="DataEncodingValidator">
<Creation Type="JavaObject">
<Class>com.ptc.csvtoinservice.validation.DataEncodingValidator</Class>
</Creation>
<Config>
<Validation code="101" description="CSV file has the wrong encoding"
resolution="File %s must be encoded in UTF8." />
</Config>
</Component>
Including Validation Entries
A validation entry in the CSVFileValidationScanner component must include the following elements:
validator: Specifies whether the validation applies to all CSV files or a specific CSV file. To do this, you define the appliesto attribute for the validator element. The following values are valid for the appliesto attribute:
Attribute Value
Description
All
Specifies whether the validation applies to all files.
<CSV_File_Name>
Specifies the name of the CSV file to which the validation applies. You must specify the relative path of the CSV file from the CSV files bundle location.
rule: Specifies the rule for the validation. The rule element has the following attributes:
Attribute
Description
type
Specifies the type of validation. The following values are valid:
file: Performs the validation on the entire CSV file.
row: Performs the validation on each row of the CSV file.
column: Performs the validation on the column specified in the columnName attribute of the rule element.
columnName
Specifies the name of a column in the CSV file. You specify the value of this attribute only when the type attribute of the rule element is set to column.
validationCriteria
Specifies the name of the validation component. The details for this validation component are specified in the customizedContext_YY.conf.xml file. For more information, see Defining Validations.
required
Specifies whether the validation is an error or warning. The following values are valid:
true: Specifies that the validation is of type error and must be resolved. This type of validation requires the user to fix the validation for successful import of the CSV file.
false: Specifies that the validation is of type warning. This type of validation is for information purpose only and does not prevent the CSV file from being imported.
The following CSVFileValidationScanner component shows an example validation entry applicable for all CSV files:
<Component Name="CSVFileValidationScanner">
<Creation Type="JavaObject">
<Class>com.ptc.csvtoinservice.main.CSVFileValidationScanner</Class>
</Creation>
<Config>
<validator appliesTo="All">
<rule type="file" columnName="" validationCriteria="DataEncodingValidator"
required="true"/>
<rule type="file" columnName="" validationCriteria="MandatoryColumnValidator"
required="true"/>
<rule type="file" columnName="" validationCriteria="EmptyLineValidator"
required="false"/>
<rule type="file" columnName="" validationCriteria="DuplicateEntryValidator"
required="false"/>
</validator>