Skip to main content

ValidateRecord

Description

Validates the Records of an incoming FlowFile against a given schema. All records that adhere to the schema are routed to the "valid" relationship while records that do not adhere to the schema are routed to the "invalid" relationship. It is therefore possible for a single incoming FlowFile to be split into two individual FlowFiles if some records are valid according to the schema and others are not. Any FlowFile that is routed to the "invalid" relationship will emit a ROUTE Provenance Event with the Details field populated to explain why records were invalid. In addition, to gain further explanation of why records were invalid, DEBUG-level logging can be enabled for the "org.apache.nifi.processors.standard.ValidateRecord" logger.

Tags

record, schema, validate

Properties

In the list below required Properties are shown with an asterisk (*). Other properties are considered optional. The table also indicates any default values, and whether a property supports the NiFi Expression Language.

Display NameAPI NameDefault ValueAllowable ValuesDescription
Record Reader *record-readerController Service:
RecordReaderFactory

Implementations:
AvroReader
CEFReader
CSVReader
ExcelReader
GrokReader
JsonPathReader
JsonTreeReader
ReaderLookup
ScriptedReader
Syslog5424Reader
SyslogReader
WindowsEventLogReader
XMLReader
YamlTreeReader
Specifies the Controller Service to use for reading incoming data
Record Writer *record-writerController Service:
RecordSetWriterFactory

Implementations:
AvroRecordSetWriter
CSVRecordSetWriter
FreeFormTextRecordSetWriter
JsonRecordSetWriter
RecordSetWriterLookup
ScriptedRecordSetWriter
XMLRecordSetWriter
Specifies the Controller Service to use for writing out the records. Regardless of the Controller Service schema access configuration, the schema that is used to validate record is used to write the valid results.
Record Writer for Invalid Recordsinvalid-record-writerController Service:
RecordSetWriterFactory

Implementations:
AvroRecordSetWriter
CSVRecordSetWriter
FreeFormTextRecordSetWriter
JsonRecordSetWriter
RecordSetWriterLookup
ScriptedRecordSetWriter
XMLRecordSetWriter
If specified, this Controller Service will be used to write out any records that are invalid. If not specified, the writer specified by the "Record Writer" property will be used with the schema used to read the input records. This is useful, for example, when the configured Record Writer cannot write data that does not adhere to its schema (as is the case with Avro) or when it is desirable to keep invalid records in their original format while converting valid records to another format.
Schema Access Strategy *schema-access-strategyUse Reader's Schema
  • Use Reader's Schema
  • Use 'Schema Name' Property
  • Use 'Schema Text' Property
Specifies how to obtain the schema that should be used to validate records
Schema Registryschema-registryController Service:
SchemaRegistry

Implementations:
AmazonGlueSchemaRegistry
ApicurioSchemaRegistry
AvroSchemaRegistry
ConfluentSchemaRegistry
Specifies the Controller Service to use for the Schema Registry

This property is only considered if:
  • the property Schema Access Strategy has a value of schema-reference-reader or schema-name
Schema Nameschema-name${schema.name}Specifies the name of the schema to lookup in the Schema Registry property

Supports Expression Language, using FlowFile attributes and Environment variables.

This property is only considered if:
  • the property Schema Access Strategy has a value of schema-name
Schema Branchschema-branchSpecifies the name of the branch to use when looking up the schema in the Schema Registry property. If the chosen Schema Registry does not support branching, this value will be ignored.

Supports Expression Language, using FlowFile attributes and Environment variables.

This property is only considered if:
  • the property Schema Access Strategy has a value of schema-name
Schema Versionschema-versionSpecifies the version of the schema to lookup in the Schema Registry. If not specified then the latest version of the schema will be retrieved.

Supports Expression Language, using FlowFile attributes and Environment variables.

This property is only considered if:
  • the property Schema Access Strategy has a value of schema-name
Schema Textschema-text${avro.schema}The text of an Avro-formatted Schema

Supports Expression Language, using FlowFile attributes and Environment variables.

This property is only considered if:
  • the property Schema Access Strategy has a value of schema-text-property
Allow Extra Fields *allow-extra-fieldstrue
  • true
  • false
If the incoming data has fields that are not present in the schema, this property determines whether or not the Record is valid. If true, the Record is still valid. If false, the Record will be invalid due to the extra fields.
Strict Type Checking *strict-type-checkingtrue
  • true
  • false
If the incoming data has a Record where a field is not of the correct type, this property determines how to handle the Record. If true, the Record will be considered invalid. If false, the Record will be considered valid and the field will be coerced into the correct type (if possible, according to the type coercion supported by the Record Writer). This property controls how the data is validated against the validation schema.
Force Types From Reader's Schema *coerce-typesfalse
  • true
  • false
If enabled, the processor will coerce every field to the type specified in the Reader's schema. If the value of a field cannot be coerced to the type, the field will be skipped (will not be read from the input data), thus will not appear in the output. If not enabled, then every field will appear in the output but their types may differ from what is specified in the schema. For details please see the Additional Details page of the processor's Help. This property controls how the data is read by the specified Record Reader.
Validation Details Attribute Namevalidation-details-attribute-nameIf specified, when a validation error occurs, this attribute name will be used to leave the details. The number of characters will be limited by the property 'Maximum Validation Details Length'.

Supports Expression Language, using FlowFile attributes and Environment variables.
Maximum Validation Details Lengthmaximum-validation-details-length1024Specifies the maximum number of characters that validation details value can have. Any characters beyond the max will be truncated. This property is only used if 'Validation Details Attribute Name' is set

Supports Expression Language, using FlowFile attributes and Environment variables.

Dynamic Properties

This component does not support dynamic properties.

Relationships

NameDescription
failureIf the records cannot be read, validated, or written, for any reason, the original FlowFile will be routed to this relationship
invalidRecords that are not valid according to the schema will be routed to this relationship
validRecords that are valid according to the schema will be routed to this relationship

Reads Attributes

This processor does not read attributes.

Writes Attributes

NameDescription
mime.typeSets the mime.type attribute to the MIME Type specified by the Record Writer
record.countThe number of records in the FlowFile routed to a relationship

State Management

This component does not store state.

Restricted

This component is not restricted.

Input Requirement

This component requires an incoming relationship.

System Resource Considerations

This component does not specify system resource considerations.

See Also