# File Validator

This component validates input data against predefined data structure.

<div align="left"><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image245.png" alt=""></div>

This component validates the contents of a single file against a specified data structure. The data structure defines the expected format of the file, including the expected number of columns, their data types, delimiters, and any required or optional fields.

When the component is executed, it reads the input file and validates each row against the specified data structure. If a row does not conform to the structure, an exception can be thrown or just ignored.

This component is useful for ensuring that input files are correctly formatted and contain all the required data before further processing. It can be used in conjunction with other components, such as FileInput and FileOutput, to create a complete data processing pipeline.

&#x20;

&#x20;

## **Input**

&#x20;

<table><thead><tr><th width="241">Attribute</th><th>Description</th></tr></thead><tbody><tr><td>Data Structure Id</td><td>Data structure for the input data validation</td></tr><tr><td>File Name</td><td>Input file name with path</td></tr><tr><td>Use Carriage Return</td><td>Use carriage return(\r) and new line(\n) for windows system?</td></tr><tr><td>Action on Error</td><td><p>Action if the validation fails.</p><ul><li>Throw Error</li><li>Response Code</li></ul><p>If Action is Response Code, the output parameter called ValidationResult will have 9 as an error indicator. And the result of the execution of this component will be treated as success.</p></td></tr><tr><td>Validation Type?</td><td>Validate type and values?</td></tr><tr><td>Validate Repeat Count</td><td><p>Validate the repeat count?</p><p>The repeat count is mostly set in the header(master) part.</p><p>If yes, this component will validate the repeat count of the input data.</p></td></tr><tr><td>Generate Parsed Contents</td><td>Generate parsed data after validation?</td></tr></tbody></table>

&#x20;

## **Output**

&#x20;

<table><thead><tr><th width="244">Attribute</th><th>Description</th></tr></thead><tbody><tr><td>ValidationResult</td><td>The result of the validation</td></tr><tr><td>ValidationResultMessage</td><td>The result message of the validation</td></tr><tr><td>ParsedContents</td><td>The parsed data</td></tr></tbody></table>

&#x20;

## **Example**

This example demonstrates a data integration workflow that retrieves a file from a remote sFTP server, validates its contents against a predefined data structure, generates a result file based on the validation outcome, and returns the result file to the same remote sFTP server. If the validation is successful, a success.txt file is generated, otherwise, a fail.txt file is generated.

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image246.png" alt=""><figcaption></figcaption></figure>

This screenshot shows the data structure and the input file.

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image247.png" alt=""><figcaption></figcaption></figure>

### FTP Input

This component collects files from the remote SFTP server and saves them as local files. The target files .txt files which contain header in the name. No suffix is entered. InputFile attribute is the only filter to collect the files.

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image248.png" alt="" width="563"><figcaption></figcaption></figure>

The input directory has one header-body.txt file.

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image249.png" alt="" width="563"><figcaption></figcaption></figure>

&#x20;

### Validate

The target file to be validated is the first file of the collected files at FTPInput component.

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image250.png" alt="" width="563"><figcaption></figcaption></figure>

### Route

If the result of the validation is success, it will proceed to Success. Otherwise, Fail component will be executed.

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image251.png" alt="" width="563"><figcaption></figcaption></figure>

### Success

Success component generates simple text file named success.txt - Validation succeeded.

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image252.png" alt="" width="563"><figcaption></figcaption></figure>

### Fail

Fail component also generates simple text file named fail.txt. And the contents are the error message from the FileValidator component.

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image253.png" alt="" width="563"><figcaption></figcaption></figure>

### FTP Output

The FTPOutput component transfers the generated file from either Success or Fail components to the same remote sFTP server.

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image254.png" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="https://support.xnarum.com/download/manuals/ISM-Manual-2023.fld/image255.png" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ism-docs.xnarum.com/tasks/file/file-validator.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
