pfx-validator:csv

Validates a CSV file or stream whether it is a valid file. It is possible to validate against a schema.

Properties

Option

Type

Default

Description

checkEmptyLines

Boolean

false

Sets NotEmptyValidator in the preValidate phase.

regularExpression

string


Sets RegexValidator in the preValidate phase.

formatRef

string


Sets IsCSVValidator in the preValidate phase.

onlyPrintWarning

Boolean

false

If set and the input contains validation errors, the errors and warnings will be printed to the logger and will not set exception on the exchange.

readNumberOfLinesOnly

Boolean

false

If set to true, the component will only read the number of lines and line separator. There will be no validations performed.

validationSchemaName

string


If set, the component will look up the schema definition from the header PfxValidatorSchema and perform validation according to the schema.

If not set or schemaName is not found, no validation will be performed (equals to readNumberOfLinesOnly option).

Examples

Using preValidator, no exception on failure

XML
<route>
              <from uri="direct:empty_line2"/>
              <to uri="pfx-validator:csv?regularExpression=RAW(.+)&onlyPrintWarning=true"/>
              <to uri="mock:empty_line2"/>
</route>


Using validationSchema defined in header

XML
<routes xmlns="http://camel.apache.org/schema/spring">
            <route>
                <from uri="direct:start"/>
                <setHeader name="PfxValidatorSchema">
                    <constant>{}</constant>
                </setHeader>
                <to uri="pfx-validator:csv?validationSchemaName=mySchema"/>
                <to uri="mock:end"/>
            </route>
        </routes>


Example of validation schema

JSON
{"name":"pm-dataload","title":"pm-dataload","description":"pm-dataload","options":{"charset":"UTF-8","delimiter":"|","escapeChar":"\\\\","quoteChar":"\\"","failFast":false,"rowCountOnly":false,"ignoreEmptyLines":true},"fields":[]}